首页 / LINUX / Linux环境下安装mysql
Linux环境下安装mysql
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Linux环境下安装mysql,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4433字,纯文字阅读大概需要7分钟。
内容图文
![Linux环境下安装mysql](/upload/InfoBanner/zyjiaocheng/452/eb55c1652aec4e9986aaa59d9994c8f7.jpg)
2、mysql安装
在Linux上安装mysql,安装方法有多种,一般是去mysql官网下载(http://dev.mysql.com/downloads/mysql/5.6.html#downloads)并安装之。还有另一种比较方便的方法就是通过yum来安装mysql。
[root@hezhixiong mysql]# yum list | grep mysql // 查看可供安装mysql版本 ……查询到的内容省略…… [root@hezhixiong mysql]# yum install -y mysql-server mysql mysql-devel // 安装mysql服务器和客户端 ……安装时输出内容省略…… [root@hezhixiong mysql]# rpm -qi mysql-server // 查看安装后的版本号
3、配置mysql
启动mysql服务
[root@hezhixiong mysql]# service mysql start // 启动mysql服务 备注: 关闭mysql服务:service mysqld stop 重启mysql服务:service mysqld restart
查看并配置开机自动启动mysql
[root@hezhixiong mysql]# chkconfig --list | grep mysqld // 查看mysql是否开机自启动 mysqld 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭 // mysql开机不启动 [root@hezhixiong mysql]# chkconfig mysqld on // 配置mysql开机启动 [root@hezhixiong mysql]# chkconfig --list | grep mysqld mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
安装后的mysql只有一个用户root,而此时root的密码为空,安全起见需要为root创建一个密码
[root@hezhixiong mysql]# mysqladmin -u root password ‘tom‘ // 为root创建密码为tom [root@hezhixiong mysql]# mysqladmin -uroot -ptom password ‘root‘ // 修改root的秘密为root [root@hezhixiong mysql]# mysql -uroot -proot // 连接mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> mysql> show databases; // 显示所有数据库 +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.00 sec)
4、mysql数据库的主要配置文件
1> /etc/my.cnf 是mysql的主配置文件
[root@hezhixiong mysql]# cat /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
2> /var/lib/mysql 是mysql数据库存放位置
[root@hezhixiong mysql]# pwd /var/lib/mysql [root@hezhixiong mysql]# ll 总用量 20488 -rw-rw----. 1 mysql mysql 10485760 7月 13 19:16 ibdata1 -rw-rw----. 1 mysql mysql 5242880 7月 13 19:16 ib_logfile0 -rw-rw----. 1 mysql mysql 5242880 7月 13 18:21 ib_logfile1 drwx------. 2 mysql mysql 4096 7月 13 18:21 mysql // 数据库mysql和test是安装mysql之后就有的默认数据库 srwxrwxrwx. 1 mysql mysql 0 7月 13 19:16 mysql.sock drwx------. 2 mysql mysql 4096 7月 13 18:21 test // 数据库mysql和test是安装mysql之后就有的默认数据库
3> /var/log 是mysql数据库存日志输出存放位置
[root@hezhixiong log]# pwd /var/log [root@hezhixiong log]# ls anaconda.ifcfg.log audit dracut.log secure anaconda.log boot.log lastlog secure-20150713 anaconda.program.log btmp maillog spooler anaconda.storage.log cron maillog-20150713 spooler-20150713 anaconda.syslog cron-20150713 messages tallylog anaconda.xlog dmesg messages-20150713 wtmp anaconda.yum.log dmesg.old mysqld.log yum.log
4> 查看mysql数据库的端口(默认端口:3306)
[root@hezhixiong log]# netstat -anp | grep mysql tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1769/mysqld unix 2 [ ACC ] STREAM LISTENING 16929 1769/mysqld /var/lib/mysql/mysql.sock
Linux环境下安装mysql
标签:
本文系统来源:http://www.cnblogs.com/hezhixiong/p/4642595.html
内容总结
以上是互联网集市为您收集整理的Linux环境下安装mysql全部内容,希望文章能够帮你解决Linux环境下安装mysql所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。