First download the MySQL Linux installation package, from the official website, I downloaded the 5.6 Community version, downloaded and uploaded to Ubuntu.
The package is placed in the ~/download directory, and the full installation command is as follows:
1, decompression tar.gz
Tar–xzf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
2. Rename the extracted folder
MV Mysql-5.6.26-linux-glibc2.5-x86_64 MySQL
3. Move the MySQL folder to the/usr/local directory
sudo mv ~/download/mysql/usr/local
4. Go to MySQL Directory
Cd/usr/local/mysql
5. Add MySQL Users and groups
sudo useradd-r MySQL
6. Change MySQL folder own and GRP to MySQL
sudo chown-r mysql:mysql mysql/
7. Execute MySQL Installation script
sudo scripts/mysql_install_db--user=mysql
(If the Libaio package is not installed, there will be an error message, after installing Libaio-dev, then run the script.) Delete Rm-rf/etc/my.cnf If you still have an error)
sudo apt-get install Libaio-dev
8, change the directory permissions back, only keep the data directory for the MySQL user
sudo chown-r root:root MySQL.
sudo chown-r mysql:mysql data
9. Copy the MySQL configuration file to the ETC directory (global configuration)
Note: The default profile name for version 5.6 is changed by the original My-medium in order to My-default.
sudo cp support-files/my-default.cnf/etc/my.cnf
10. Start MySQL
sudo bin/mysqld_safe--user=mysql &
11. Initialize the MySQL root user password
sudo bin/mysqladmin-u root-p ' user-defined password ';
#ps-a|grep MySQL
Show similar:
1829? 00:00:00 Mysqld_safe
1876? 00:00:31 mysqld
2. #kill-9 1829
3. #kill-9 1876
12, copy Mysql.server script to/ETC/INIT.D (initialization service, some people like to change to MySQL, change here can)
sudo cp support-files/mysql.server/etc/init.d/mysql.server
14. View MySQL Running status
sudo service mysql.server status
If it works, MySQL running will be displayed.
If not running is displayed, the service should not be started earlier, and can be started directly with service Mysql.server start
sudo service mysql.server [status|start|stop]
15. Let MySQL boot [defaults], cancel boot [remove]
sudo update-rc.d-f mysql.server defaults [remove]
16. Add the Mysql/bin/mysql command to the user command, or add the Mysql/bin directory to the path
To join the user command:
sudo ln-s/usr/local/mysql/bin/mysql/usr/local/bin/mysql
Add Environment variables:
Export path= $PATH:/usr/local/mysql/bin
17. Allow root users to log in remotely
1> into Mysql:mysql–u root–p
2> Change database: use MySQL;
3> login from any host: Grant all privileges on * * to [email protected] '% ' identified by ' cipher text ' with GRANT option;
4> login from specified host: Grant all privileges on * * to [email protected] ' 192.168.1.101 ' identified by ' passw0rd ' with GRANT option;
5> authorization entry into force: flush privileges;
6> See if the host is added for% authorization: SELECT * from user;
7> View Database Character set: Show variables like ' character% ';
After we start MySQL, we can then test it and use the "MySQL" command to access the MySQL database console.
$mysql-U Root
Here the reason for using-u root is because I am now a general user (Firehare), if you do not add-u root, MySQL will assume that it is firehare log in. Note that I do not have access to root user mode here because it is not necessary. In general, the database in MySQL operation, there is no need to enter the root user mode, only in the setting of this possibility.
After entering MySQL, the most important thing is to set up the root user password in MySQL, otherwise, the MySQL service is not safe to say.
Mysql> GRANT All privileges on * * to [e-mail protected] identified by "123456";
If you need to use root for remote access from other machines, you can use
Mysql> GRANT All privileges on * * to [e-mail protected] "%" identified by "123456";
Note that I use 123456 as the root user's password, but the password is not secure, please use a combination of uppercase and lowercase letters and numbers, and not less than 8 bits.
Configuration file Reference:
[HTML]View PlainCopy
- # for advice The change settings
- # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
- # * * * Don't EDIT this FILE. It ' s a template which'll be copied to the
- # * * * default location during install, and would be replaced if you
- # * * * * Upgrade to a newer version of MySQL.
- [Client]
- Port = 3306
- default-character-set=UTF8
- # Here's entries for some specific programs
- # The following values assume you has at least 32M RAM
- [Mysqld]
- character_set_server=UTF8
- lower_case_table_names=1
- init_connect=' SET NAMES UTF8 '
- lower_case_table_names=1
- max_connections=
- Max_allowed_packet = 32M
- Thread_cache_size =
- Thread_concurrency = 8
- Query_cache_size = 128M
- # Remove Leading # and set to the amount of RAM for the most important data
- # Cache in MySQL. Start at 70% of all RAM for dedicated server, else 10%.
- # innodb_buffer_pool_size = 128M
- # Remove Leading # to turn on a very important data integrity option:logging
- # Changes to the binary log between backups.
- # Log_bin
- # These is commonly set, remove the # and set as required.
- # Basedir = ...
- # DataDir = ...
- # port = ... ..
- # server_id = ...
- # socket = ... ..
- # Remove Leading # To set options mainly useful for reporting servers.
- # The server defaults is faster for transactions and fast selects.
- # Adjust sizes as needed, experiment to find the optimal values.
- join_buffer_size = 16M
- sort_buffer_size = 16M
- # read_rnd_buffer_size = 2M
- Sql_mode=no_engine_substitution,strict_trans_tables
- [Mysqldump]
- Quick
- Quote-names
- Max_allowed_packet = 32M
- [MySQL]
- No-auto-rehash
Reference article: http://blog.csdn.net/njchenyi/article/details/17615391
Install MySQL diagram under Ubuntu 12.04