知识点017-编译安装mysql

来源:转载

一、下载源码包


wgethttp://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz



二、解压源码包


[[email protected] software]# tar -xzvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz


三、复制解压后的mysql目录


[[email protected] software]# mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql


四、添加用户组和用户


groupadd mysql


useradd-g mysql mysql


五、安装


切换目录:[[email protected] software]# cd /usr/local/mysql/


更改权限:chown-R mysql:mysql ./


./scripts/mysql_install_db--user=mysql --datadir=/usr/local/mysql/data/mysql


[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data


[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld


[[email protected] mysql]# chmod 755 /etc/init.d/mysqld


[[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf


六、修改启动脚本


[[email protected] mysql]# vim /etc/init.d/mysqld


七、测试连接


[[email protected] local]# pwd /usr/local [[email protected] local]# ./mysql/bin/mysql -uroot

八、加入环境变量


编辑 /etc/profile,这样可以在任何地方用mysql命令了


[[email protected] local]# vim /etc/profile


在最后添加



[[email protected] local]# source /etc/profile


九、启动、关闭、状态


启动mysql


service mysqld start


关闭mysql


service mysqld stop


查看运行状态


service mysqld status


十、报错问题处理


[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist。


[[email protected] local]# more /etc/my.cnf |grep -v ^#


正常情况下为空值


[client] socket=/usr/local/mysql/data/mysql/mysql.sock [mysqld] datadir=/usr/local/mysql/data/mysql socket=/usr/local/mysql/data/mysql/mysql.sock user=mysql old_passwords=1


[mysqld_safe] log-error=/usr/local/mysql/data/mysql/mysqld.log pid-file=/usr/local/mysql/data/mysql/mysqld.pid


#由于编译安装时指定的路径为/opt/data以及mysql_install_db时指定的datadir也为/opt/data,而my.cnf为缺省的路径 #因此修改datadir至正确路径后,问题解决


操作命令记录


tar -xf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
ls
mv mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql
id mysql
groupadd mysql
useradd -g mysql mysql
id mysql
df -h
cd
cd /app
ls
mkdir data
chown -R mysql.mysql data
ll
cd /usr/local/mysql/
ls
cd scripts/
ls
./mysql_install_db --basedir=/usr/local/mysql/ --datadir=/app/data/
ll /app/data/
cd ../
ls
cd support-files/
ls
cp mysql.server /etc/init.d/mysqld
cd
chmod 755 /etc/init.d/mysqld
vi /etc/my.cnf
/etc/init.d/mysqld start
mysql
/usr/local/mysql/bin/mysql
history

分享给朋友:
您可能感兴趣的文章:
随机阅读: