linux安装mysql 5.6.33

1.到mysql官网下载mysql编译好的二进制安装包,在下载页面Select Platform:选项选择linux-generic,然后把页面拉到底部,64位系统下载Linux - Generic (glibc 2.5) (x86, 64-bit),下载后文件名:mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
2.解压64位安装包:
进入安装包所在目录,执行命令:tar xzvfmysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
3.复制解压后的mysql目录到系统的本地软件目录:
执行命令:cp mysql-5.6.33-linux-glibc2.5-x86_64/usr/local/mysql -r
注意:目录结尾不要加/
4.添加系统mysql组和mysql用户:
执行命令:groupadd mysql和useradd -r -g mysql mysql
5.安装数据库:
进入安装mysql软件目录:执行命令 cd/usr/local/mysql
修改当前目录拥有者为mysql用户:执行命令chown-R mysql:mysql ./
安装数据库:执行命令./scripts/mysql_install_db--user=mysql
修改当前目录拥有者为root用户:执行命令chown-R root:root ./
修改当前data目录拥有者为mysql用户:执行命令chown -R mysql:mysql data
到此数据库安装完毕

6.启动mysql服务和添加开机启动mysql服务:
添加开机启动:执行命令cp support-files/mysql.server /etc/init.d/mysql,把启动脚本放到开机初始化目录

chmod +x /etc/init.d/mysql    赋予可执行权限

chkconfig --add mysql        添加服务
chkconfig --list            显示服务列表

如果看到mysql的服务,并且3,4,5都是on的话则成功,如果是off,则键入
chkconfig --level 345 mysql on

启动mysql服务:执行命令service mysql start

执行命令:ps -ef|grep mysql 看到mysql服务说明启动成功。

7.修改mysql的root用户密码,root初始密码为空的:

执行命令:./bin/mysqladmin -u rootpassword '密码'
如果报错:
/usr/bin/mysqladmin: connect toserver at 'localhost' failed
error: 'Can't connect to local MySQL server through socket'/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock'exists!

(1)先停止服务:service mysql stop
(2)修改/etc/my.conf:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
If there is not currently asection called [client], add one at the bottom of the file and copy the socket=line under the [mysqld] section such as:
[client]
socket=/var/lib/mysql/mysql.sock

(3)执行/usr/local/mysql/bin/mysqld_safe& service mysql start
(4)无密码root帐号登陆
/usr/bin/mysql -uroot -p 【注释,在下面的要求你输入密码的时候,你不用管,直接回车键一敲就过去了】
Enter password:
Welcome to the MySQL monitor. Commandsend with ; or \g.
…………
Type 'help;' or '\h' for help.Type '\c' to clear the current input statement.
mysql> use mysql;
Database changed
(5) 手动update修改密码
mysql> update user setpassword=password("新密码") where user='root' andhost='localhost';
Query OK, 1 row affected (0.00sec)
Rows matched: 1 Changed: 1 Warnings:0
mysql> flush privileges;
Query OK, 0 rows affected (0.00sec)
mysql> quit
Bye
8.正常重新启动mysql服务登录 mysql -uroot -p
9.把mysql客户端放到默认路径:
ln -s/usr/local/mysql/bin/mysql /usr/local/bin/mysql
注意:建议使用软链过去,不要直接包文件复制,便于系统安装多个版本的mysql


  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值