Home >Database >Mysql Tutorial >centos6.9 reinstall msyql5.6 record

centos6.9 reinstall msyql5.6 record

远方*
远方*Original
2022-03-10 11:12:37224browse

Uninstall the original version mysql

1. yum remove mysql mysql-server mysql-libs compat-mysql51
2. rm -rf /var/lib/mysql
3. rm -rf / var/lib64/mysql
4. rm /etc/my.cnf
5. Check if there is still mysql software. If it exists, continue to delete it.
Command: rpm -qa|grep -i mysql
MySQL-server-5.6.17-1.el6.i686
MySQL-client-5.6.17-1.el6.i686
Command: rpm -e MySQL-server-5.6.17-1.el6.i686
rpm -e MySQL-client-5.6.17-1.el6.i686
6. Delete mysql service
chkconfig –list | grep -i mysql
chkconfig –del mysql
7. Delete scattered mysql folders
whereis mysql
mysql: /usr/lib/mysql /usr/share/mysql
Clear related mysql All directories and files:
rm -rf /usr/lib/mysql
rm -rf /usr/share/mysql
After the above steps, mysql should have been completely uninstalled.

Install new mysql

Mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz
1. Unzip
tar -zxf mysql- 5.6.30-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
2. Folder rename
mv mysql-5.6.30-linux-glibc2.5-x86_64 mysql
3. Create mysql user
useradd mysql
4. Set mysql user password
echo '123456'|passwd –stdin mysql
5. Set permissions:
chown -R mysql:mysql usr/local/mysql/
6, switch to mysql user
su - mysql
7, install
cd /usr/local/mysql/scripts/
./mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data
8. Copy file
cd /usr/local/mysql/support-files/
cp my-default. cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysql
9. Modify the two changed values ​​​​in the file
basedir=/usr/local/mysql
datadir =/usr/local/mysql/data
10. Configure environment variables

vi /etc/profileexport MYSQL_HOME=/usr/local/mysqlexport PATH=$MYSQL_HOME/bin:$PATH

Save and exit
source /etc/profile
11. Set startup
chkconfig –add mysql
chkconfig mysql on
12. Start
service mysql start

What to do if you forget your password

1. Stop the original service and start mysql in login-free mode
service mysql stop
mysqld_safe –skip-grant-table
2. Change password

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;FLUSH PRIVILEGES;

% in the above statement can be replaced with specific The IP address, 123456, can also be changed to a more complex password, which will provide higher security.
3. Restart the service
service mysql start;

The above is the detailed content of centos6.9 reinstall msyql5.6 record. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn