一、MySQL 安装方式
(1) RPM :RPM 软件包是一种在 Linux 平台下的安装文件,MySQL 的 RPM 安装文件包分为服务器端和客户端两种
(2) Generic Binaries :二进制软件包,经过编译生成的二进制文件软件包
(3) 源码包 :源码包是 MySQL 数据库的源代码,用户需要自己编译成二进制文件之后才能安装
二、MySQL RPM包 目录
(1) /usr/bin :客户端和脚本
(2) /usr/sbin :mysqld 服务器
(3) /var/lib/mysql :日志文件和数据库
(4) /usr/share/info :信息格式的手册
(5) /usr/share/man :Unix 帮助页
(6) /usr/include/mysql :头文件
(7) /usr/lib/mysql :库
(8) /usr/share/mysql :错误消息、字符集、示例配置文件等
三、MySQL RPM包
(1) mysql-client-5.7.18-1.el6.x86_64.rpm :客户端的安装包
(2) mysql-server-5.7.18-1.el6.x86_64.rpm :服务端的安装包
(3) mysql-devel-5.7.18-1.el6.x86_64.rpm :包含开发用的库头文件安装的包
(4) mysql-shared-5.7.18-1.el6.x86_64.rpm :包含 MySQL 共享库文件的安装包
(5) mysql-test-5.7.18-1.el6.x86_64.rpm :一些测试的安装包
(6) mysql-embedded-5.7.18-1.el6.x86_64.rpm :嵌入式 MySQL 的安装包
四、安装 MySQL
yum install -y autoconf libaio-devel groupadd mysql useradd -s /sbin/nologin -g mysql -M mysql cd /usr/local/src wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz tar -zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz mv mysql-5.6.36-linux-glibc2.5-x86_64 mysql && mv mysql /usr/local/ chown -R mysql.mysql /usr/local/mysql/ mkdir /usr/local/mysql/data cd /usr/local/mysql ./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql cp support-files/mysql.server /etc/init.d/mysqld /bin/cp support-files/my-default.cnf /etc/my.cnf chmod +x /etc/init.d/mysqld /etc/init.d/mysqld start chkconfig --add mysqld chkconfig mysqld on echo 'export PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile echo 'export PATH=\$PATH:/usr/local/mysql/bin' >> ~/.bash_profile source ~/.bash_profile 2>/dev/null五、配置 MySQL
[root@root mysql]# mysqladmin -u root password 'pzk123'
[root@root mysql]# mysql -uroot -ppzk123
mysql> drop database test;
mysql> drop user "root"@"::1";
mysql> drop user ""@"localhost";
mysql> delete from mysql.user where user='' and host='www' ;
mysql> delete from mysql.user where user='root' and host='www';
mysql> flush privileges;