Methods to install MySQL and turn on MySQL remote access in CentOS systems

  • 2020-12-10 00:53:41
  • OfStack

Install MySQL

Install MySQL and ES6en-ES7en


[root@sample ~]# yum -y install mysql-server  
[root@sample ~]# yum -y install php-mysql  

Configuration MySQL


[root@sample ~]#vim /etc/my.cnf   The editor MySQL Configuration file of 
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).

find


old_passwords=1 

This 1 line, add a new rule below this 1 line, make MySQL default to ES22en-8, add


default-character-set = utf8 

The 1 row
Then add the following statement at the end of the configuration file:
[mysql]


default-character-set = utf8

Start the MySQL service

[root@sample ~]# chkconfig mysqld on
Set up the MySQL service to start with system boot

[root@sample ~]# chkconfig --list mysqld
Verify that MySQL starts automatically

mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
If 2- 5 is on then OK

[root@sample ~]#/etc/rc.d/init.d/mysqld start
Start the MySQL service

Initializing MySQL database:         [ OK ]
Starting MySQL:              [ OK ]

Open remote access to MySQL services

Modify database configuration:

Authorize root user to make remote connection. Note that "password" is replaced with the real password of root user:


[root@sample ~]#vim /etc/my.cnf   The editor MySQL Configuration file of 
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
0

Command 2 puts the Settings into effect, and you can connect immediately.

PS: Ubuntu system requires:


[root@sample ~]#vim /etc/my.cnf   The editor MySQL Configuration file of 
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
1 Find:

[root@sample ~]#vim /etc/my.cnf   The editor MySQL Configuration file of 
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
2 To:

bind-address = 0.0.0.0
# Allow any ip Address access 
You can also specify the IP address. Then restart MySQL:

[root@sample ~]#vim /etc/my.cnf   The editor MySQL Configuration file of 
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
4


Related articles: