linux6.5 RPM方式安装 mysql5.6

步骤一、检查下linux是不是已经安装了MySQL

# rpm -qa|grep mysql
mysql-libs-5.1.71-1.el6.x86_64

# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64  //卸载

# find / -name mysql//有mysql文件夹的话,把mysql的文件夹删掉

步骤二、下载需要的安装包,下载地址:

https://dev.mysql.com/downloads/mysql/5.6.html#downloads

步骤三、将下载的文件进行解压:

# tar -xvf MySQL-5.6.41-1.el6.x86_64.rpm-bundle.tar 
MySQL-client-5.6.41-1.el6.x86_64.rpm
MySQL-shared-compat-5.6.41-1.el6.x86_64.rpm
MySQL-test-5.6.41-1.el6.x86_64.rpm
MySQL-server-5.6.41-1.el6.x86_64.rpm
MySQL-devel-5.6.41-1.el6.x86_64.rpm
MySQL-shared-5.6.41-1.el6.x86_64.rpm
MySQL-embedded-5.6.41-1.el6.x86_64.rpm

步骤四、按顺序依次安装:

rpm -ivh MySQL-devel-5.6.41-1.el6.x86_64.rpm
rpm -ivh MySQL-server-5.6.41-1.el6.x86_64.rpm
rpm -ivh MySQL-client-5.6.41-1.el6.x86_64.rpm

没有ERROR日志,说明安装成功;

步骤五、启动mysql

# service mysql start
Starting MySQL.Logging to '/var/lib/mysql/C5-3_SOA23.cnpc.com.cn.err'.
   [  OK  ]

步骤六、查看默认密码

# cat /root/.mysql_secret 

步骤七、登录

# mysql -u root -p

遇到的问题:

1、登录时,报错

# mysql -uroot -p
mysql: unknown variable 'sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES'

解决方式:

# vi /etc/my.cnf

把 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 这句话注释掉;

2、要使用sql语句,必须重设password

mysql> use mysql
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

解决方式:

mysql> SET PASSWORD = PASSWORD('123456');//123456是新密码

3、设置远程登录:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql> flush privileges;

posted @ 2018-09-07 11:42  lijinshan2018  阅读(2909)  评论(0编辑  收藏  举报