How to install MySQL and open MySQL remote access in CentOS system _mysql

Source: Internet
Author: User

installing MySQL

Installing MySQL and Php-mysql

[Root@sample ~]# yum-y Install Mysql-server 

Configure MySQL

[Root@sample ~] #vim/etc/my.cnf edit MySQL configuration file
[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 MYSQ LCLIENT10 compatibility package).

Found it

Old_passwords=1

This line, add a new rule below this line, let MySQL's default encoding be UTF-8, add

Default-character-set = UTF8

This line
Then add the following statement to the end of the text in the configuration file:
[MySQL]

Default-character-set = UTF8

Start the MySQL service
[Root@sample ~]# chkconfig mysqld on
Set the MySQL service to boot from the system
[Root@sample ~]# chkconfig--list mysqld
Confirm MySQL from boot
Mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Ok if 2--5 is on
[Root@sample ~]#/etc/rc.d/init.d/mysqld start
Start the MySQL service
Initializing MySQL database: [OK]
starting mysql: [OK]

Open MySQL Service remote access

To modify the database configuration:

Authorize the root user to connect remotely, noting that replacing "password" with the root user's real password:

Grant all privileges on *.* to root@ '% ' identified by ' password ' with GRANT option;
Flush privileges;

The second line commands the settings to take effect and can be connected immediately.

The Ps:ubuntu system requires the following:

Vim/etc/mysql/my.cnf
Found it:
Bind-address = 127.0.0.1
To
bind-address = 0.0.0.0
#允许任意ip地址访问
You can also specify an IP address. Then restart MySQL:
Sudo/etc/init.d/mysqld restart

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.