How to uninstall the CentOS system comes with MySQL
1.1. find out if MySQL was previously installed
Command: Rpm-qa|grep-i MySQL
Can be seen as shown: (Pictures from the Internet, only for reference use)
Description System comes with:
Mysql-client-5.5.25a-1.rhel5
Mysql-server-5.5.25a-1.rhel5
1.2. Stop the MySQL service, delete the previously installed MySQL
1) Stop service Command: (MySQL service command has two kinds: one is MySQL, one is mysqld)
Stop mode 1:service MySQL stop
Stop mode 2:/etc/init.d/mysql shutdown
Stop mode 3:service mysqld stop
Stop mode 4:/etc/init.d/mysqld shutdown
2) Delete mysql command:rpm–e (Delete command) rpm-e–nodeps (Force Delete command)
For example:
Rpm-ev Mysql-client-5.5.25a-1.rhel5
Rpm-e–nodeps Mysql-server-5.5.25a-1.rhel5
1.3, query the old version of MySQL directory, and delete the old version of MySQL files and libraries
1) Query command: Find/-name MySQL
For example:
/var/lib/mysql
/var/lib/mysql/mysql
/usr/lib64/mysql
2) Delete command: RM–RF
For example:
Rm-rf/var/lib/mysql
Rm-rf/var/lib/mysql
Rm-rf/usr/lib64/mysql
Note: /etc/my.cnf will not be removed after uninstallation, manual removal is required
Rm-rf/etc/my.cnf
1.4. Find out if the machine installs MySQL again
Using the query command: rpm-qa|grep-i MySQL
No results, instructions have been uninstalled thoroughly, next install MySQL directly
Second, How to install MySQL online in the CentOS system 1.1 . View the MySQL version with the yum command
View version online command: Yum list | grep MySQL
(Pictures from the Internet, only for reference use)
1.2. Install MySQL online via the yum command
Online installation command:yum install (single install) Yum Install–y (multiple installations)
For example:
Yum Install Mysql-server
Yum install–y mysql-server MySQL Mysql-deve
Installation success: (Pictures from the Internet, only for reference use)
1.3. View the install installed version command
View installed versions command: Rpm-qi mysql-server
third, How to manually install MySQL in the CentOS system 1.1. Download the MySQL installation file
1) If you just need to install MySQL, then only need to install the following files
Mysql-server-5.5.25-1.rhel5(recommended download version, high version requires Compatibility Pack)
Mysql-devel-5.5.25-1.rhel5(recommended download version, high version requires Compatibility Pack)
Mysql-client-5.5.25-1.rhel5(recommended download version, high version requires Compatibility Pack)
1.2. manual MySQL installation
1) Open the terminal and go to the folder directory where the MySQL installer is placed
such as: Cd/opt/install
2) install mysql server
Install the RMP File installation command:RPM–IVH
Install the bin file installation command:./
RPM-IVH mysql-server-5.5.25a-1.rhel5.x86_64.rpm
./mysql-server-5.5.25a-1.rhel5.x86_64.bin
Note: An error occurred during the installation: (workaround)
Error message:
[Email protected] upload]# RPM-IVH mysql-server-5.5.25a-1.rhel5.x86_64.rpm
error:failed dependencies:
Libaio.so.1 () (64bit) is needed by mysql-server-5.5.25a-1.rhel5.x86_64
Libaio.so.1 (libaio_0.1) (64bit) is needed by mysql-server-5.5.25a-1.rhel5.x86_64
Libaio.so.1 (libaio_0.4) (64bit) is needed by mysql-server-5.5.25a-1.rhel5.x86_64
The above error message can be seen because the library Libaio is missing, so you need to download the Libaio library installation
The installation method is consistent with the installation of the MySQL method
3) install mysql client,mysql-devel
RPM-IVH mysql-client-5.5.25a-1.rhel5.x86_64.rpm
./mysql-client-5.5.25a-1.rhel5.x86_64.bin
RPM-IVH mysql-devel-5.5.25a-1.rhel5.x86_64.rpm
./mysql-devel-5.5.25a-1.rhel5.x86_64.bin
Installation success: (Pictures from the Internet, only for reference use)
Iv. How to perform MySQL initialization and related configuration 1.1. turn on MySQL service command
Start mode 1:service mysql start
Start Mode 2:/etc/init.d/mysql start
Starting mode 3:service mysqld start
Start Mode 4:/etc/init.d/mysqld start
1.2. Modify root initial password in MySQL
After installing MySQL successfully, the root initial password is empty.
Enter MySQL interface command: Mysql–u root–p
(Pictures from the Internet, only for reference use)
Modify Initialization Password command:/usr/bin/mysqladmin-u root password ' rootadmin '
Format: Mysqladmin-u username-P Old password password new password
Note: If you are unable to access the MySQL interface, there are 2 common cases
A: Service not started
A: Password error (refer to 1.3, how to reset the MySQL root user password)
Other error: Please contact QQ: 807002272
1.3. How to reset the root user password and authentication in MySQL
Ø How to change the root password
1) Stop the MySQL service command:
/etc/init.d/mysqld Stop
/etc/init.d/mysql stop
2) Enter the bypass password Authentication command :
Mysqld_safe--user=mysql--skip-grant-tables--skip-networking &
3) Enter the login user command:
Mysql-u Root MySQL
4) Enter the change root password SQL statement:
Update user set password=password ('123456') where user= ' root ';
5) Enter data Refresh command:
FLUSH privileges;
6) exit the MySQL command:
Quit
Ø Verify that the root password has been modified successfully
1) login MySQL interface: mysql–u root–p (new password modified)
Example: Mysql–u root–p123456
1.4. How to implement MySQL remote connection
Note: MySQL access port must be open in the CentOS system firewall
1) Change the table method:
Mysql-u Root-pvmware
mysql> use MySQL;
mysql> Update user Set host = '% ' where user = ' root ';
Mysql> Select Host, user from user;
mysql> flush Privileges;
Mysql> quit;
2) Authorization law:
Mysql> Grant all privileges on * * to ' myuser ' @ '% ' identified by ' MyPassword ' with GRANT OPTION;
Mysql> GRANT All privileges on * * to ' myuser ' @ ' 192.168.1.3 ' identified by ' MyPassword ' with GRANT OPTION;
1.5, How to implement automatic start MySQL service
1) Check whether the MySQL service automatically opens the command
Chkconfig--list | grep mysqld
Chkconfig--list | grep MySQL
2) turn on the MySQL service auto-open command
Chkconfig mysqld on
Chkconfig MySQL on
v. how to open, close, and restart MySQL service commands
Start mode 1:service mysql start
Start Mode 2:/etc/init.d/mysql start
Starting mode 3:service mysqld start
Start Mode 4:/etc/init.d/mysqld start
Stop mode 1:service MySQL stop
Stop mode 2:/etc/init.d/mysql shutdown
Stop mode 3:service mysqld stop
Stop mode 4:/etc/init.d/mysqld shutdown
Restart mode 1:service mysql restart
Restart Mode 2:/etc/init.d/mysql Restart
Restart mode 3:service mysqld restart
Restart Mode 4:/etc/init.d/mysqld Restart
Vi. How to set up a centos firewall open port
Ø Open the iptables configuration file command:
Vi/etc/sysconfig/iptables
Ø Add make Firewall Open port command:
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport port -j ACCEPT
Ø shut down , Open, and restart the firewall command:
/etc/init.d/iptables Stop shutdown
/etc/init.d/iptables Start Open
/etc/init.d/iptables Restart Restart
Ø permanently shut down the firewall command:
Chkconfig--level iptables off
/etc/init.d/iptables stop
Iptables-p INPUT DROP
Ø Open Active mode port command
Iptables-a input-p TCP--dport Port-j ACCEPT
Ø Open the command between the passive mode port ~ Port
Iptables-a input-p TCP--dport port : Port -j ACCEPT
Iptables-a input-i lo-j ACCEPT
Iptables-a input-m State--state established-j ACCEPT
Entos system installation MySQL tutorial