In comparison with centos install a lot more pit, it is not recommended.
First, the software installation
There are two common ways under Ubuntu
- apt-get mode (similar to yum)
- deb packages mounted (similar package rpm)
1. Download and unzip
Software Download: http://dev.mysql.com/downloads/mysql/
This package contains mysql software tar all deb packages
- Create the installation directory: mkdir / usr / local / mysql
- Transferring .tar file to the installation directory
- Enter the installation directory and extract:
cd /usr/local/mysql
tar -xvf mysql-server_5.6.34-1ubuntu14.04_amd64.deb-bundle.tar
2. deb package installation
-
Dependent relationship between packages, in order to install
sudo dpkg -i mysql-common_5.6.34-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqlclient18_5.6.34-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqlclient-dev_5.6.34-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqld-dev_5.6.34-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-community-server_5.6.34-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-server_5.6.34-1ubuntu14.04_amd64.deb
- Install Client
sudo dpkg -i mysql-community-client_5.6.34-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-client_5.6.34-1ubuntu14.04_amd64.deb
Precautions:
- mysql-community-server_5.6.34-1ubuntu14.04_amd64.deb mounted reliance libaio1 package, if the installation is not being given.
Download: http://packages.ubuntu.com/zh-cn/precise/libaio1
- You will be prompted to set up (mysql's) root user password mysql-community-server_5.6.34-1ubuntu14.04_amd64.deb installation.
3. Modify the parameter file
Other possible with default values, but below this must be changed (do not change the root user may not log on)
Modifying bind-address = 127.0.0.1 to bind-address = 0.0.0.0, this line or directly Zhushidiao
http://blog.csdn.net/fhxpp_27/article/details/8442555
4. Initialize the database
./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql3306
5. Start mysql service
service mysql start
If you do not mind using default parameters, run mysql -uroot -p so far has been able to log in normally
Second, modify the data directory location
Fairly standard installation is not the default location of mysql, change the law under centos with not all the same.
1. Create a new directory and copy the original data
mkdir -p /data/mysql
cp -R /var/lib/mysql/* /data/mysql
chown -R mysql:mysql /data/mysql
chmod –R 775 /data/mysql
2. Modify the parameter file
vim /etc/mysql/my.cnf
#修改
datadir = /data/mysql
3. Modify the startup file
Note that this step must be changed Ubuntu, centos do not need to, otherwise it will error
vim /etc/apparmor.d/usr.sbin.mysqld
#把
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
#改成
/data/mysql/ r,
/data/mysql/** rwk,
4. Restart Service
/etc/init.d/apparmor restart
/etc/init.d/mysql restart