1. Find and uninstall the original mysql
method 1
rpm -qa|grep mysql
rpm -e filename
Method 2
yum list installed mysql*
yum remove mysql mysql-devel mysql-server mysql-libs compat-mysql51
Method 3
find / -name mysql
then rm -rf file
2. Download the installation package
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
(If it reports -bash: wget: command not found, it means that wget is not installed and needs to be installed. The installation command is as follows: yum -y install wget)
3. Unzip the installation package and modify the file name
tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz -C /data/my/
mv mysql-5.7.17-linux-glibc2.5-x86_64/ mysql5.7
Create data, log folders
mkdir /data/my/mysql5.7/data
mkdir /data/my/mysql5.7/logs
4. Configuration
Overwrite /etc/my.cnf with my.cnf from the attachment
Overwrite /data/my/mysql5.7/bin/mysqld_safe with mysqld_safe from the attachment
Copy the mysqld in the attachment to /etc/init.d/
5. Initialize mysql
cd /data/my/mysql5.7/bin
./mysqld --initialize --user=root --basedir=/data/my/mysql5.7 --datadir=/data/my/mysql5.7/data
初始化中如出现 error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
//It is OK to initialize after installation
yum install -y libaio
6. Start mysql
./mysqld_safe --user=root &
After initialization, a temporary password root@localhost::******* will be generated, which can be viewed in the log file configured in my.cnf
and then check whether mysql starts
ps -ef|grep mysql
注意可能会遇到:does not exist or is not executable. Please cd to the mysql installation
directory and restart this script from there as follows:
./bin/mysqld_safe&
See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information
In MySQL 5.7, the security is improved, and it is required to switch to the software installation directory to start the database
[root@localhost ~]# cd /mysql_software_57/
[root@localhost mysql_software_57]# bin/mysqld_safe --defaults-file=/ etc/my.cnf &
[1] 25341
7. Modify the password and set the remote connection
enter the client
./mysql -uroot -p
Enter password: Enter a temporary password
Modify password
mysql> set password=password('newpassword');
Change the root user's host to %
mysql>use mysql;
mysql>select host, user from user;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
Set remote access account: grant all privileges on . to remote access username@'%' identified by 'user password';
mysql> grant all privileges on *.* to root@'%' identified by 'newpassword';
refresh:
mysql > flush privileges;
exit mysql
mysql> exit;
// Linux关闭MySQL的命令
$mysql_dir/bin/mysqladmin -uroot -p shutdown
8. Set the boot to start automatically
empowerment
chmod 777 /etc/init.d/mysqld
chmod -R 777 /data/my/mysql5.7
add service mysql
chkconfig --add mysqld
set the service to self-start
chkconfig mysqld on
Finally restart the server to try the effect
reboot
Reference: https://www.cnblogs.com/ivictor/p/6846017.html#conclusion
http://blog.csdn.net/yougoule/article/details/56680952