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 typingmysql
sudo su
Your manually installed MySQL 5.6.8 might refuse to start if AppArmor is running, therefore we disable AppArmor: linux
/etc/init.d/apparmor stop update-rc.d -f apparmor remove apt-get remove apparmor apparmor-utils
First we create a user and group called mysql:sql
groupadd mysql useradd -r -g mysql mysql
Next install the libaio1 package:数据库
apt-get install libaio1
Next:下载和安装app
下载:能够在Oracle 官网下载离线包:我下载的为mysql-5.6.12-linux-glibc2.5-i686.tar.gzide
将离线包复制到 /usr/local下this
Unpack MySQL, rename the directory to mysql, and make it owned by the user and group mysql:spa
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 .
Runserver
scripts/mysql_install_db --user=mysql
在这里可能会出现错误:ip
Installing MySQL system tables..../bin/mysqld: error whileloading shared libraries: libaio.so.1: cannot open shared objectfile: No such file or directory
解决办法:
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天体验,以后我相信你们会有办法的)