Install mysql in linux.

Source: Internet
Author: User
: Slave has been copied to usrlocal) # tarzxvfmysql-5.5.22-li

: Http://dev.mysql.com/downloads/mysql/ 1, add user group # groupadd mysql 2, add user # useradd-r-g mysql 3, switch directory # cd/usr/local 4 decompress (mysql-5.5.22-linux2.6-i686.tar.gz has been copied to/usr/local) # tar zxvf mysql-5.5.22-li

:
Http://dev.mysql.com/downloads/mysql/


1. Add a user group
#> Groupadd mysql
2. Add a user
#> Useradd-r-g mysql
3. Switch the Directory
#> Cd/usr/local
4、decompress (mysql-5.5.22-linux2.6-i686.tar.gz has been copied to/usr/local)
#> Tar zxvf mysql-5.5.22-linux2.6-i686.tar.gz
5. Create a soft link
#> Ln-s mysql-5.5.22-linux2.6-i686 mysql
6. Delete the compressed package (operable)
#> Rm mysql-5.5.22-linux2.6-i686.tar.gz
7. Enter the mysql directory
#> Cd mysql
8. Change user and group permissions
#> Chown-R mysql.
#> Chgrp-R mysql.
9. initialize the database
<1> make sure that the my. cnf and mysql folders are not in the/etc/directory. If yes, delete them.
<2> install libaio1.so and run sudo apt-get install libaio1 to skip this step.
#> Scripts/mysql_install_db -- user = mysql


If the initialization is successful, the following message is displayed:
Installing MySQL system tables...
OK
Filling help tables...
OK


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


Please remember to set a password for the MySQL root USER!
To do so, start the server, then issue the following commands:


./Bin/mysqladmin-u root password 'root'
./Bin/mysqladmin-u root-h VWmare password 'new-password'


Alternatively you can run:
./Bin/mysql_secure_installation


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


See the manual for more instructions.


You can start the MySQL daemon:
Cd ..;./bin/mysqld_safe &


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


Please report any problems with the./bin/mysqlbug script!


10. Modify permissions
#> Chown-R root.
#> Chown-R mysql data


11. Copy the configuration file
#> Cp support-files/my-medium.cnf/etc/my. cnf
#> Cp support-files/mysql. server/etc/init. d/mysql. server


12. Start the database
#> Bin/mysqld_safe -- user = mysql &


13. Check whether port 3306 is enabled.
#> Netstat-nat


14. Set the password
#>./Bin/mysqladmin-u root password 'new-password'
Or
#>./Bin/mysql_secure_installation


15. use mysql
#> Cd bin
#>./Mysql-u root-p


16. Set automatic start upon startup
#> Cd/etc/init. d/
Sudo update-rc.d mysql. server defaults

17. Set the default encoding to UTF8.

Log on to MySQL and run the encoding:

Show variables like 'character % ';

QUOTE:

+ -------------------------- + ---------------------------- +
| Variable_name | Value |
+ -------------------------- + ---------------------------- +
| Character_set_client | latin1 |
| Character_set_connection | latin1 |
| Character_set_database | latin1 |
| Character_set_filesystem | binary |
| Character_set_results | latin1 |
| Character_set_server | latin1 |
| Character_set_system | utf8 |
| Character_sets_dir |/usr/share/mysql/charsets/|
+ -------------------------- + ---------------------------- +


Sudo vi/etc/mysql/my. cnf


Find [client] and add:



Default-character-set = utf8

Find [mysqld] and add:


Default-character-set = utf8

Init_connect = 'set NAMES utf8'


Sudo/etc/init. d/mysql. server restart

After modification, restart mysql.


If an exception occursChange [mysqld]

Character_set_server = utf8

Init_connect = 'set NAMES utf8'


QueryShow variables like 'character % ';

QUOTE:

+ -------------------------- + ---------------------------- +
| 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/share/mysql/charsets/|
+ -------------------------- + ---------------------------- +

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.