1:下载安装cmake (mysql5.5以后是通过cmake来编译的)
2:创建mysql的安装目录及数据库存放目录
#mkdir /usr/mysql //安装mysql
#mkdir /usr/mysql/data //存放数据库
3:创建mysql用户及用户组
#groupadd mysql
#useradd -g mysql -s /bin/
false
-M mysql
4:安装mysql
tar -zxv -f /root/mysql-5.6.26.tar.gz
cd mysql-5.6.26
cmake
-DCMAKE_INSTALL_PREFIX=/usr/mysql -DMYSQL_DATADIR=/usr/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=
all
-DENABLED_LOCAL_INFILE=1
centos7 需要执行
cmake -DCMAKE_INSTALL_PREFIX=/usr/mysql -DMYSQL_DATADIR=/usr/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost
如果报错则需要安装
yum -y install ncurses-devel
rm -f CMakeCache.txt
make
make install
5:配置MySQL
cd /usr/mysql
chown -R root:mysql .
chown -R mysql:mysql data
6:
cp support-files/my-
default
.cnf /etc/my.cnf
7:初始化权限表
scripts/mysql_install_db
--user=mysql --basedir=/usr/mysql --datadir=/usr/mysql/data
8:启动MySQL服务
cd /usr/mysql/support-files
cp mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
service mysqld start
8. centos7 mysql5.7按照上述步骤完成安装后权限设置
sevice mysqld stop
cd /usr/mysql/bin
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql -u root mysql
mysql -u root mysql
update user set authentication_string=password('123456') where user='root';
FLUSH PRIVILEGES;
exit;
FLUSH PRIVILEGES;
exit;
service mysql restart #必须是重启服务器
mysql -uroot -p
Enter password: 123456
Enter password: 123456
mysql> #出现此界面说明成功
mysql> SET PASSWORD = PASSWORD('1234567'); #再次登入之后需要重新修改默认密码
mysql> use mysql;
mysql>update user set host = '%' where user ='root';#修改任意IP可以访问
mysql>select host, user from user;
mysql>flush privileges;