Download the source package to MySQL website for example: mysql-5.6.16.tar.gz
Decompression TAR-XVF mysql-5.6.16.tar.gz
Necessary environment preparation
-
install CMake
-
sudo apt-get install cmake
-
Best is up-to-date, if the software center is not up-to-date, you can go to CMake's official download source package to compile and install
-
install g++ compiler sudo apt-get install g++
-
install dependent libraries Libncurses sudo Apt-get install Libncurses5-dev
Create two directories, the MySQL home directory (basedir) and MySQL Data directory (mysqldata)
Example: sudo mkdir/opt/mysql_5.6 sudo mkdir/opt/mysqldata
into the source directory of the newly unzipped MySQL, using CMake for the configuration of the compilation environment
With the following parameters:
sudo cmake.
-dcmake_install_prefix=/opt/mysql_5.6 (Specifies the directory to install to)
-dmysql_datadir=/opt/mysqldata (Specify Data directory)
-ddefault_charset=utf8 (Specifies the DB character set)
-ddefault_collation=utf8_general_ci (key sentence for solving Chinese garbled characters)
-dextra_charsets=all
-denabled_local_infile=1
This step is only for the compilation of the configuration, not the actual installation, just in the current directory generated makefile
sudo make sudo make install (these two are the actual compilation installation)
The above steps are complete, MySQL is already installed, but not yet initialized
To MySQL installed Basedir, execute sudo scripts/mysql_install_db--user=root
Perform initialization of the database, generate some db (such as test,mysql, etc.), followed by the specified user
-
generate MySQL configuration file
sudo cp support-files/my-default.cnf/etc/my.cnf
After you specify the corresponding parameters in the mysqld, for example:
DataDir =/ Opt/mysqldata
Port = 3306
Finally can start the database, because the password has not been specified, so the first time not to enter a password, a safe mode to start the database
sudo bin/mysqld_safe--user=root
Set a password for the root user to enter the database in Safe mode
Use MySQL;
UPDATE user SET Password=password (' 123456 ') WHERE user= ' root ';
FLUSH privileges;
Alternatively, enable the script directly in the bin directory: mysqladmin-u root-p password Password
Register MySQL for Ubuntu system service
sudo cp $MYSQL _home/support-files/mysql.server/etc/init.d/mysql.server
sudo chmod +x/etc/init.d/mysql.server
Let MySQL boot up
sudo update-rc.d-f mysql.server defaults
Cancel boot up sudo update-rc.d-f mysql.server remove
- Modify MY.CNF, specify MySQL's startup user to modify MY.CNF, and add "User=root" line under the [MYSQLD] block.
- Use of services
Start MySQL:service mysql.server start;
Stop MySQL:service MySQL. Server stop;
check MySQL running status: service MySQL. SERVER  status .
Add the MySQL startup script to the PATH environment variable,
sudo gedit/etc/environment
After the environment variable, add:/opt/mysql_5.6/bin
That's the bin directory inside your MySQL basedir.
Source/etc/environment (Let it take effect immediately)