Install MySQL in CentOS and enable MySQL remote access. centosmysql
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
Articles you may be interested in:
- How to compile and install MySQL and set the yum source in CentOS
- How to compile a shell script in CentOS to monitor MySQL master-slave Replication
- How to reset the root password of MySQL in CentOS
- To upgrade MySQL 5.1 to MySQL 5.5 in CentOS
- How to install Mysql5.5 in Centos5.5
- Install and configure the LAMP server in CentOS 6.4 (Apache + PHP5 + MySQL)
- Install and configure the LNMP server in CentOS 6.4 (Nginx + PHP + MySQL)
- Centos6 install php mysql gd using yum
- How to install MySQL 5.5 in CentOS 5.5
- Detailed configuration of CentOS + Nginx + PHP + MySQL (illustration)