比尔云BierYun--阿里云最新优惠活动
阿里云优惠码丨阿里云代金券

linux使用压缩包安装MySql

linux使用压缩包安装MySqlhttp://www.bieryun.com/3297.html

1. 下载安装包

https://dev.mysql.com/downloads/mysql/

按需选择版本,我这是使用的是5.6.39

2. 拷贝安装包到/home/mysql目录,并解压

tar -zxvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz

 

* 安装目录如果选在/usr/local/mysql会省掉一些麻烦,因为有些配置默认的是/usr/local/mysql。所以这是一个不好的示例,哈哈哈

3. 创建数据目录

mkdir data

最终的目录结构是这样的

安装目录:/home/mysql/mysql-5.6.39-linux-glibc2.12-x86_64

数据目录:/home/mysql/mysql-5.6.39-linux-glibc2.12-x86_64/data

4. 添加系统mysql组和mysql用户:

执行命令:groupadd mysql和useradd -r -g mysql mysql

5. 初始化数据库

./mysql-5.6.39-linux-glibc2.12-x86_64/scripts/mysql_install_db –user=mysql –basedir=/home/mysql/mysql-5.6.39-linux-glibc2.12-x86_64 –datadir=/home/mysql/data

初始化过程中有以下提示:

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/home/mysql/mysql-5.6.39-linux-glibc2.12-x86_64/bin/mysqladmin -u root password ‘new-password’
/home/mysql/mysql-5.6.39-linux-glibc2.12-x86_64/bin/mysqladmin -u root -h localhost.localdomain password ‘new-password’
You can start the MySQL daemon with:
cd . ; /home/mysql/mysql-5.6.39-linux-glibc2.12-x86_64/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
New default config file was created as /home/mysql/mysql-5.6.39-linux-glibc2.12-x86_64/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

 

6. 添加启动服务

cp mysql-5.6.39-linux-glibc2.12-x86_64/support-files/mysql.server /etc/init.d/mysql

* 这里就需要注意第二条提到的目录的问题,因为mysql.server默认的是/usr/local/mysql,如果安装目录不是这个,就需要修改。修改如下:

basedir=/home/mysql/mysql-5.6.39-linux-glibc2.12-x86_64

datadir=/home/mysql/data

7. 启动mysql

service mysql start

 

8. 登录

./home/mysql/mysql-5.6.39-linux-glibc2.12-x86_64/bin/mysql -u root -p

9. 远程登录失败

在服务器上登录mysql,然后执行以下命令(记得修改为自己的用户/密码)。再次尝试远程登录后成功

GRANT ALL PRIVILEGES ON *.* TO ‘myuser’@’%’ IDENTIFIED BY ‘mypassword’ WITH GRANT OPTION;

FLUSH   PRIVILEGES;

未经允许不得转载:阿里云代理商 » linux使用压缩包安装MySql
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

强烈推荐

高性能SSD云服务器ECS抗攻击,高可用云数据库RDS