This article mainly introduces how to install MySQL and enable MySQL remote access in CentOS, including the introduction of MySQL random start and other operations. For more information, see
Install MySQL
Install MySQL and php-mysql
[root@sample ~]# yum -y install mysql-server [root@sample ~]# yum -y install php-mysql
Configure MySQL
[Root @ sample ~] # Vim/etc/my. cnf edit MySQL configuration file [mysqld] datadir =/var/lib/mysqlsocket =/var/lib/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 line, add new rules under this line, let MySQL default encoding as UTF-8, add
default-character-set = utf8
This line
Add the following statement at the end of the configuration file:
[Mysql]
default-character-set = utf8
Start MySQL service
[root@sample ~]# chkconfig mysqld on
Set the MySQL service to start with the system
[root@sample ~]# chkconfig --list mysqld
Confirm that MySQL is self-started
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
If 2-5 is on, OK is returned.
[root@sample ~]#/etc/rc.d/init.d/mysqld start
Start MySQL service
Initializing MySQL database: [ OK ]Starting MySQL: [ OK ]
Open remote access to MySQL
Modify database configuration:
Authorize the root user to remotely connect. replace "password" with the real password of the root user:
grant all privileges on *.* to root@"%" identified by "password" with grant option;flush privileges;
The second line of command to make the settings take effect, you can connect immediately.
PS: In Ubuntu, you need:
vim /etc/mysql/my.cnf
Find:
bind-address = 127.0.0.1
Changed:
Bind-address = 0.0.0.0 # Allow access from any IP address
You can also specify an IP address. Then restart MySQL:
sudo /etc/init.d/mysqld restart
The above is how to install MySQL in CentOS and enable MySQL remote access _ MySQL content. For more information, see PHP Chinese network (www.php1.cn )!