1 Preliminary Note
Because we must run all the steps from this tutorial with root privileges, we can either prepend all commands in this tutorial with the string sudo, or we become root right now by typingsudo su
2 Disabling AppArmor
Your manually installed MySQL 5.6.8 might refuse to start if AppArmor is running, therefore we disable AppArmor:/etc/init.d/apparmor stop
update-rc.d -f apparmor remove
apt-get remove apparmor apparmor-utils
3 Installing MySQL 5.6.8rc1 (Linux Generic)
First we create a user and group called mysql:groupadd mysql
useradd -r -g mysql mysql
Next install the libaio1 package:apt-get install libaio1
Next:下载和安装
下载:可以在Oracle 官网下载离线包:我下载的为mysql-5.6.12-linux-glibc2.5-i686.tar.gz
将离线包复制到 /usr/local下
Unpack MySQL, rename the directory to mysql, and make it owned by the user and group mysql:tar xvfz mysql-5.6.12-linux-glibc2.5-i686.tar.gz
mv mysql-5.6.12-linux-glibc2.5-i686 mysql
cd mysql
chown -R mysql .
chgrp -R mysql .
Runscripts/mysql_install_db --user=mysql
在这里可能会出现错误:
Installing MySQL system tables..../bin/mysqld: error whileloading shared libraries: libaio.so.1: cannot open shared objectfile: No such file or directory
解决办法:
这说明还要安装一个libaio的依赖库:
sudo apt-get install libaio-dev
然后重新执行:scripts/mysql_install_db --user=mysql
to create the necessary databases (like the mysql database):
Change some ownerships:chown -R root .
chown -R mysql data
MySQL uses the my.cnf file inside /usr/local/mysql, so we don't have to create one on our own. If you want to change MySQL settings, you can do it in that file.
The downloaded MySQL package comes with the init script mysql.server which we copy to /etc/init.d as follows:cp support-files/mysql.server /etc/init.d/mysql.server
It is already executable, so we don't have to change permissions.
We can now start MySQL 5.6 as follows:/etc/init.d/mysql.server start
To make MySQL start automatically at boot time, run the following command:update-rc.d mysql.server defaults
The MySQL commands (like mysql, mysql_secure_installation, etc.) are located in the /usr/local/mysql/bin directory which is not in the PATH which means we would have to call these commands with the full or relative path which is cumbersome. To avoid this, we create the following symlink so that we can call all MySQL commands without a path:
ln -s /usr/local/mysql/bin/* /usr/local/bin/
Finally, we should set a MySQL root password:
mysql_secure_installation
root@server1:/usr/local/mysql# mysql_secure_installation
启动MySQL服务: sudo start mysql
停止MySQL服务: sudo stop mysql
修改 MySQL 的管理员密码: sudo mysqladmin -u root password newpassword
设置远程访问(正常情况下,mysql占用的3306端口只是在IP 127.0.0.1上监听,拒绝了其他IP的访问(通过netstat可以查看到)。取消本地监
听需要修改 my.cnf 文件:):
sudo vi /etc/mysql/my.cnf
bind-address = 127.0.0.1 //找到此内容并且注释
4)MySQL安装后的目录结构分析(此结构只针对于使用apt-get install 在线安装情况):
数据库存放目录: /var/lib/mysql/
相关配置文件存放目录: /usr/share/mysql
相关命令存放目录: /usr/bin(mysqladmin mysqldump等命令)
启动脚步存放目录: /etc/rc.d/init.d/
5)MySQL图形化管理软件
一般使用的有两个比较好,一个开源,一个商业收费:
开源:MySQL Workbench (具体使用介绍随着我的使用,我会慢慢总结)
商业:Navicat (收费的,有30天体验,之后我相信大家会有办法的)