Install MySQL in CentOS and enable MySQL remote access _ MySQL

Source: Internet
Author: User
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 )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.