CentOS_6.6用rpm方式安装MySql
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
CentOS_6.6用rpm方式安装MySql
卸载旧版本MySql
检查MySQL及相关RPM包,是否安装,如果有安装,则移除
[root@MyServer010 ftp]# rpm -qa|grep mysql
mysql-libs-5.1.73-3.el6_5.x86_64
[root@MyServer010 ftp]# yum -y remove mysql-libs*
移除MySql也可以用下面的命令
rpm -e --nodeps mysql-libs-5.1.73-3.el6_5.x86_64
下载的MySql文件
[root@MyServer010 ftp]# ll
-rw-r--r-- 1 root root 18596528 10月21 14:31 MySQL-client-5.6.27-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 3392620 10月21 14:31 MySQL-devel-5.6.27-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 55950588 10月21 14:32 MySQL-server-5.6.27-1.el6.x86_64.rpm
安装MySql
[root@MyServer010 ftp]# rpm -ivh MySQL-server-5.6.27-1.el6.x86_64.rpm
注意:
安装server时,会有下面的提示,会告知root第一次登录所需的随机密码文件位置。
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.
You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.
Also, the account for the anonymous user has been removed.
In addition, you can run:
/usr/bin/mysql_secure_installation
下面接着安装
[root@MyServer010 ftp]# rpm -ivh MySQL-devel-5.6.27-1.el6.x86_64.rpm
[root@MyServer010 ftp]# rpm -ivh MySQL-client-5.6.27-1.el6.x86_64.rpm
初始化数据库及设置密码
[root@MyServer010 ftp]# /usr/bin/mysql_install_db
[root@MyServer010 ftp]# service mysql start
Starting MySQL.. SUCCESS!
[root@MyServer010 ftp]# cat /root/.mysql_secret
# The random password set for the root user at Wed Oct 21 14:56:09 2015 (local time): _zh41DmKP_Zzw7vn
密码为红字,下面登录MySql
[root@MyServer010 ftp]# mysql -uroot -p_zh41DmKP_Zzw7vn
修改密码:
mysql> set password = password('admin');
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
[root@MyServer010 ftp]# mysql -uroot -padmin
以新密码登录成功,则表示新密码设置完成。
允许远程登陆
mysql> use mysql;
mysql> select host, user, password from user;
+-------------+------+-------------------------------------------+
| host | user | password |
+-------------+------+-------------------------------------------+
| localhost | root | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
| myserver010 | root | *72963C165975618B2D2D329E3550572F964D524A |
| 127.0.0.1 | root | *72963C165975618B2D2D329E3550572F964D524A |
| ::1 | root | *72963C165975618B2D2D329E3550572F964D524A |
+-------------+------+-------------------------------------------+
4 rows in set (0.00 sec)
mysql> update user set password=password('admin') where user='root';
mysql> update user set host='%' where user='root' and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> exit;
设置开机自启动
[root@MyServer010 ftp]# chkconfig mysql on
[root@MyServer010 ftp]# chkconfig --list | grep mysql
mysql 0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭
MySQL的默认安装位置
1 /var/lib/mysql/ #数据库目录
2 /usr/share/mysql #配置文件目录
3 /usr/bin #相关命令目录
4 /etc/init.d/mysql #启动脚本