Installation Environment:
Linux version: centost6.5
mysql version: 5.6.31
MySQL installation method: rpm installation
mysql file download address: http://pan.baidu.com/s/1jHZN0LS
You can also go to the official website to download
Check if it is installed, grep's -i option means ignore case when matching
[root@localhost soft]#rpm -qa|grep -i mysql
mysql-libs-5.1.71-1.el6.x86_64
MySQL-python-1.2.3-0.3.c1.1.el6.x86_64
mysql-5.1.71-1.el6.x86_64
mysql-connector-odbc-5.1.5r1144-7.el6.x86_64
It can be seen that the library file has been installed and should be uninstalled first, otherwise an overwrite error will occur. Note that the --nodeps option is used when uninstalling, ignoring dependencies, and you need to uninstall all installed mysql files
[root@localhost soft]#rpm -e mysql-libs-5.1.71-1.el6.x86_64--nodeps
Start installing mysql: install mysql server
rpm -ivh MySQL-server-5.6.31-1.el6.x86_64.rpm
Wait for the automatic installation command to end, try to start the mysql service: service mysql satrt
Starting MySQL.[ OK ]
You can check whether MySQL starts normally by checking whether the port is open: netstat -anp|grep 3306
tcp 0 0 :::3306 :::* LISTEN 15211/mysqld
Next, start installing the mysql client:
rpm -ivh MySQL-client-5.6.31-1.el6.x86_64.rpm
If the installation is successful, you should be able to run the mysql command. Note that the mysqld service must be enabled and enabled:
输入命令:mysql,如果能够正常进入,那就OK了
如果报错:Access denied for user 'root'@'localhost' (using password: NO)
则需要输入命令:/usr/bin/mysqld_safe --skip-grant-tables,然后再新开一个窗口,再输入mysql,就可以进入,OK了。
然后再修改密码:
mysql>use mysql
mysql>update user set password=password("123456") where user="root";
mysql>flush privileges;
mysql>exit
然后通过命令:mysql -uroot -p 进入mysql,选择mysql数据库,如果报错:You must SET PASSWORD before executing this statement,只需要再输入一次修改密码的命令就OK了:SET PASSWORD = PASSWORD('123456');
到此mysql安装结束