CentOS Install MySQL---glibc mode

Source: Internet
Author: User
Tags mysql host mysql in mysql version mysql command line

Write in front:

First, CentOS is integrated with MySQL itself. But the server I'm going to use is not being installed.

Secondly, CentOS can be installed with Yum MySQL, I am happy and easy to use Yum to install MySQL. But it's frustrating when it's running. Yum installed MySQL, when reloading SQLAlchemy, reported a fullscreen error. I look at the full screen of all kinds of mistakes. MySQL was not familiar.

Finally, had to go to the MySQL website, down source code pack, 1.1 points of installation down. It cost me a whole day. Below I will record this process, later use is convenient.

Download MySQL:

http://downloads.mysql.com/archives.php

Choose a MySQL version, then be sure to look good, under the glibc. such as: mysql-5.0.90-linux-i686-glibc23.tar.gz

In this example download to the/media directory, this is not a good habit ...

▲ Install MySQL:

Here is the Linux command

[Plain]View PlainCopy
    1. : $ sudo groupadd mysql
    2. : $ sudo useradd-g mysql MySQL
    3. : $ cd/usr/local
    4. : $ tar zvxf/media/mysql-5.0.90-linux-i686-glibc23.tar.gz
[Plain]View PlainCopy
    1. : $ mv mysql-5.0.90-linux-i686-glibc23 MySQL
[Plain]View PlainCopy
    1. : $ cd MySQL
    2. : $ sudo chown-r mysql.
    3. : $ sudo chgrp-r mysql.
    4. : $ scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql
    5. :& CD.
    6. : $ sudo chown-r root mysql.
    7. : $ cd MySQL
    8. : $ sudo chown-r mysql data
    9. : $ bin/mysqld_safe--basedir=/usr/local/mysql--user=mysql &

At this point, MySQL installation is successful.

Because in the running state, I did not ctrl-c, had to open another SSH window ...

▲ Add a password for the root user of MySQL

Here is the Linux command

[C-sharp] view plain copy
    1. Cd/usr/local/mysql/bin./mysql-u Root

After entering MySQL:

[C-sharp]View PlainCopy
    1. Mysql> GRANT All privileges on * * to [e-mail protected] identified by "Chang";

is actually set the root of the localhost password for Chang
The display executes successfully, and then exit exits MySQL.

After that, log in to MySQL again, this time with a password:

[C-sharp]View PlainCopy
    1. Cd/usr/local/mysql/bin./mysql-u root-p

After entering the password Chang, you can log in normally, as follows:

Welcome to the MySQL Monitor. Commands End With; Or/g.
Your MySQL Connection ID is 1
Server version:5.0.90 MySQL Community Server (GPL)

Type ' help; ' or '/h ' for help. Type '/C ' to clear the current input statement.

To view the user information:

[C-sharp]View PlainCopy
    1. Mysql> select User,host,password from Mysql.user;

The results are as follows:

+------+-----------+----------+
| user | Host | password |
+------+-----------+----------+
| Root |  localhost |   *F05D019BA3BEC01CA9FBD4141E4EA57A28EF3EDF | ← (root password is Chang)
| Root |            Linux |   | ← (The root password is empty)
| Root |           127.0.0.1 |   | ← (The root password is empty)
| |           localhost | |
+------+-----------+----------+

Change their passwords individually:

[C-sharp]View PlainCopy
    1. mysql> Set password for [email Protected]=password (' Chang ');

[C-sharp]View PlainCopy
    1. mysql> Set password for [email Protected]=password (' Chang ');

[C-sharp]View PlainCopy
    1. mysql> Set password for [email Protected]=password (' Chang ');

Viewing the user information again will reveal that the changes have been made.

Then quit MySQL.

▲ Make MySQL Service

[C-sharp]View PlainCopy
    1. sudo cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysql

Start the MySQL service

[C-sharp]View PlainCopy
    1. Sudo/etc/init.d/mysql start

It's time to restart the machine and try it.
Restart and then log in to MySQL, found can log on. Service Production Success!

▲ Configuring MySQL

[C-sharp]View PlainCopy
    1. Vi/etc/my.cnf

(Note: If the my.cnf file is not automatically generated, then: There is a support-files folder under the MySQL package installed, including MY-HUGE.CNF, etc., will my-huge copy a copy, renamed to MY.CNF, Modify it appropriately (depending on your database configuration, of course) and copy to/ETC/MY.CNF)

After opening my.cnf

Find [client] Add:
Default-character-set = UTF8 # default character set is UTF8

Find [mysqld] Add:
Default-character-set = UTF8 #默认字符集为utf8
Init_connect = ' SET NAMES UTF8 ' #设定连接mysql数据库时使用utf8编码 to let MySQL database run for UTF8

After you have modified it, restart it.
I am here to restart the MySQL service:

[C-sharp]View PlainCopy
    1. Sudo/etc/init.d/mysql restart


(One time I can't find sock, so I can restart the service after two times!!! Sweat. )

Then go to MySQL and check if the character set is changed:

[C-sharp]View PlainCopy
    1. Cd/usr/local/mysql/bin./mysql-u root-p

[C-sharp]View PlainCopy
    1. Mysql> Show variables like ' character% ';

The following screen appears:

+--------------------------+----------------------------------------+
| variable_name | Value |
+--------------------------+----------------------------------------+
| character_set_client | UTF8 |
| character_set_connection | UTF8 |
| Character_set_database | UTF8 |
| Character_set_filesystem | binary |
| Character_set_results | UTF8 |
| Character_set_server | UTF8 |
| Character_set_system | UTF8 |
| Character_sets_dir | /usr/local/mysql/share/mysql/charsets/|
+--------------------------+----------------------------------------+

OK, the database language is complete.

▲ Open remote access to MySQL
MySQL does not allow remote access by default.
Log in to MySQL with a password, you can normally log in, but the machine with the tool to connect, the error:
ERROR 1130:host 192.168.1.6 isn't allowed to connect to this MySQL server

Methods: The table method was changed. MySQL is not allowed remote access by default and can only be accessed on localhost. This time, as long as the computer on the localhost, log in to MySQL, change the "MySQL" Database in the "User" table "host", from "localhost" to "%"

Mysql-u root-p
Enter Password:chang
Mysql>use MySQL;
Mysql>update User Set host = '% ' where user = ' root '; Could be an error.
Mysql>flush privileges;
Mysql>select host,user from user where user= ' root ';

After executing the above, you can connect remotely!

Comments:

Update user Set host = '% ' where user = ' root '; When this command is executed, an error may be encountered:
ERROR 1062 (23000): Duplicate entry '%-root ' for key 1;
Workaround:
1, don't care about it. Oh.
2, change to do so
Update user set host= '% ' where user= ' root ' and host= ' localhost ';
That is, change localhost to all hosts.

---------------------------------------------------
After running the app, error:
Importerror:libmysqlclient_r.so.15:cannot open Shared object file:no such file or directory

The solution is to put the/usr/local/mysql/lib under the
libmysqlclient_r.so.15
Copy to/usr/lib resolution.

At this point, MySQL installation configuration is complete!

================= I'm gorgeous split-line ========================

----------------------------------------------------
Note
Note 1: Restarting and shutting down the MySQL service
Restart MySQL Service
: $ sudo/etc/init.d/mysql Restart
Turn off MySQL service
: $ sudo/etc/init.d/mysql Stop
----------------------------------------------------
Note 2: Start and stop MySQL in a non-service state
Start MySQL
Code:
:& Cd/usr/local/mysql
:& bin/mysqld_safe--basedir=/usr/local/mysql--user=mysql &

Stop MySQL
Code:
:& Cd/usr/local/mysql
: $ bin/mysqladmin-uroot-ppassw0rd shutdown

----------------------------------------------------
Note 3:mysql command line Chinese display No.
mysql> set names UTF8;

---------------------------------------------------
Note 4:mysql the database storage path
/var/lib/mysql

---------------------------------------------------
Note 5: Exporting and importing data from MySQL
Mysqldump database name > file name #导出数据库
Mysqladmin CREATE database name #建立数据库
MySQL database name < file name #导入数据库

---------------------------------------------------
Note 6: Modify the root password of MySQL
sudo mysqladmin-u root-p password ' Your new password '

Or: The new password in parentheses
Use MySQL;
Update user set Password=password (' Chang ') where user= ' root ';
Flush privileges;

---------------------------------------------------
Note 7: What to do if you forget the root password of MySQL
Sudo/etc/init.d/mysql stop
sudo mysqld_safe--skip-grant-tables &
sudo mysqladmin-u user password ' NewPassword
sudo mysqladmin flush-privileges

---------------------------------------------------
Note 8: Enter the MySQL host to log in
./mysql-u root-h 127.0.0.1-p

CentOS Install MySQL---glibc mode

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.