linux 上安装mysql
Posted wyl9527
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 上安装mysql相关的知识,希望对你有一定的参考价值。
1.基本信息
版本 | 5.5.39 |
---|---|
安装机器 | 172.24.5.173 |
账号 | root |
源路径 | /opt/software/mysql_5.5.39_product6.5_new.tar.gz |
目标路径 |
/usr/local/mysql |
依赖关系 | 无 |
2.安装过程
1).登陆172.24.5.173,切换用户名root,并进入软件包所在目录:
[root @bgs -5p173-wangwenting opt]# exit [root @bgs -5p173-wangwenting opt]# cd /opt/software |
2).配置mysql用户(密码也设置为mysql):
[root @bgs -5p173-wangwenting software]# groupadd mysql [root @bgs -5p173-wangwenting software]# useradd -r -g mysql mysql |
3).将mysql-5.5.39.tar.gz通过tar -xf命令解压缩至目的安装目录,,并设置软连接,配置目录归属为mysql账户、mysql群。如
[root @bgs -5p173-wangwenting software]# tar -zxvf mysql-${version}.tar.gz -C /usr/local [root @bgs -5p173-wangwenting software]# chown -R mysql:mysql /usr/local/mysql-${version} [root @bgs -5p173-wangwenting software]# ln -s /usr/local/mysql-${version}/ /usr/local/mysql [root @bgs -5p173-wangwenting software]# cd /usr/local [root @bgs -5p173-wangwenting software]# chown -R mysql:mysql mysql* [root @bgs -5p173-wangwenting software]# ln -s /usr/local/mysql/lib/libmysqlclient.so. 18.0 . 0 /usr/lib64/libmysqlclient.so. 18 (防止出现找不到libmysqlclient.so. 18 的错误) |
4).初始化mysql:
[root @bgs -5p173-wangwenting software]# cd /usr/local/mysql [root @bgs -5p173-wangwenting software]# scripts/mysql_install_db --user=mysql [root @bgs -5p173-wangwenting software]# cp support-files/my-medium.cnf /etc/my.cnf [root @bgs -5p173-wangwenting software]# cp support-files/mysql.server /etc/init.d/mysql.server |
5).启动mysql服务:
[root @bgs -5p173-wangwenting software]# /usr/local/mysql/support-files/mysql.server start 若出现Starting MySQL.. SUCCESS!结果代表启动成功。 |
6).在172.24.5.173上启动Mysql,进入mysql,修改密码以及权限:
# mysql -u root -p
mysql> set password = password("1234");
mysql> GRANT ALL PRIVILEGES ON *.* TO \'root\'@\'%\' IDENTIFIED BY \'1234\';
mysql> GRANT ALL PRIVILEGES ON *.* TO \'root\'@baseline01 IDENTIFIED BY \'1234\';
mysql>flush privileges;
进入mysql,且密码修改成功,则表示mysql安装和启动成功。
[root @bgs -5p173-wangwenting software]# mysql -u root -p mysql> set password = password( "1234" ); mysql> GRANT ALL PRIVILEGES ON *.* TO \'root\' @ \'%\' IDENTIFIED BY \'1234\' ; mysql> GRANT ALL PRIVILEGES ON *.* TO \'root\' @bgs -5p173-wangwenting IDENTIFIED BY \'1234\' ; mysql>flush privileges; 进入mysql,且密码修改成功,则表示mysql安装和启动成功。 |
以上是关于linux 上安装mysql的主要内容,如果未能解决你的问题,请参考以下文章