Simple configuration for MySQL under Linux

Source: Internet
Author: User

1. Set character encoding
Enter the command:
[Root@localhost ~]# vi/etc/my.cnf
Last line join: Default-character-set=utf8, Save!
2. Start the MySQL service:
Enter the command:
[root@localhost ~]# Service mysqld start
Returning information indicates that it has been started successfully
Initializing mysql database:installing mysql system tables ...
Ok
Filling Help Tables ...
Ok

To start mysqld at boot time with to copy
Support-files/mysql.server to the right place for your system

REMEMBER to SET A PASSWORD for the MySQL root USER!
To does so, start the server, then issue the following commands:

/usr/bin/mysqladmin-u root password ' new-password '
/usr/bin/mysqladmin-u root-h localhost.localdomain password ' new-password '

Alternatively you can run:
/usr/bin/mysql_secure_installation

Which would also give you the option of removing the test
Databases and anonymous user created by default. This is
Strongly recommended for production servers.

See the Manual for more instructions.

You can start the MySQL daemon with:
CD/USR; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
Cd/usr/mysql-test; Perl mysql-test-run.pl

Problems with The/usr/bin/mysqlbug script!

                                                       [  OK  ]

Starting mysqld: [OK]

3. Set Boot start:
Enter the command:
[Root@localhost ~]# Chkconfig–add mysqld
[Root@localhost ~]# chkconfig mysqld on

4. Check if the boot setting is successful
Enter the command:
[Root@localhost ~]# Chkconfig–list | grep MySQL mysqld
Returning information indicates that it has been set successfully
Grep:mysqld:No such file or directory
[Root@localhost ~]# Chkconfig–list | grep MySQL

Mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

5. Create Root administrator:
Input command: (set user name to root, password is 123456)
[root@localhost ~]# mysqladmin-u root password 123456

6. Login database:
Enter the command:
[Root@localhost ~]# mysql-u root-p
Enter Password:
Returning information indicates a successful login
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 3
Server version:5.1.73 Source Distribution

Copyright (c) and/or, Oracle, its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

Mysql>

7, if your MySQL database is installed on the virtual machine Linux side, you may encounter the problem of remote access, the solution is as follows:
(1) Modify the firewall, open 3306 port.
Input command:
[root@localhost ~]# vi/etc/sysconfig/iptables
Add one line:
-A input-m state–state new-m tcp-p TCP–DPO RT 3306-j ACCEPT
(2) Restart service
Input command:
[root@localhost ~]# service iptables Restart
return information:
Iptables:flushing Firewall rules: [OK]
iptables:setting chains to policy accept:filter [OK]
iptables:unloading modules: [OK ]
iptables:applying firewall rules: [OK]
(3) authorized users from remote login
Specific steps: Login to MySQL
First use MySQL;
mysql> update User set host= '% ' where user = ' root ';
Return information:
ERROR 1062 (23000): Duplicate entry '%-root ' for key ' PRIMARY '
then view the following database host information as follows:
Mysql> Select Host from user where user = ' root ';
+ ——————— –+
| host |
+ ——————— –+
|% |
| 127.0.0.1 |
| localhost.localdomain |
+ ——————— –+
3 rows in Set (0.00 sec)
Host already has this value, so run the command directly:
Mysql>flush privileges;

Congratulations, so far, you can log on the remote login successfully.

Simple configuration for MySQL under Linux

Related Article

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.