Linux系统上安装MySQL数据库
来源:互联网 发布:淘宝买来的模板怎么装 编辑:程序博客网 时间:2024/06/07 01:28
原文:http://www.cnblogs.com/shihaiming/p/6251209.html
1.mysql5.7.17安装在/usr/local/mysql目录里面,也可以安装在其他地方
(安装包最好与Linux系统一样,eg;32位的就是“mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz”,官网可下载)
mkdir /usr/local/mysql
2.解压并复制
tar -xvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz(我是手动解压的)
mv mysql-5.7.17-linux-glibc2.5-x86_64/* /usr/local/mysql/
3.创建data目录(很重要!)
mkdir /usr/local/mysql/data
4.创建mysql用户和修改权限
groupadd mysql
chown -R mysql.mysql /usr/local/mysql/
5.初始化数据
进入到mysql文件下:cd /usr/local/mysql
[root@localhost mysql] ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
2016-01-20 02:47:35 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2016-01-20 02:47:45 [WARNING] The bootstrap log isn't empty:
2016-01-20 02:47:45 [WARNING] 2016-01-19T18:47:36.732678Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2016-01-19T18:47:36.750527Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2016-01-19T18:47:36.750560Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
6. 复制配置文件到 /etc/my.cnf
cp -a ./support-files/my-default.cnf /etc/my.cnf (选择y)
7. mysql的服务脚本放到系统服务中
cp -a ./support-files/mysql.server /etc/init.d/mysqld
修改my.cnf文件 (vim /etc/my.cnf)
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
# server_id = .....
socket = /tmp/mysql.sock
character-set-server = utf8
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
修改完了之后再最下面输入命令 :mq
8.启动mysql
service mysqld start
ps -ef #查看是启动
9.查看初始化自动生成的密码: cat /root/.mysql_secret (记住并复制下来,等会登陆mysql需要)
10.输入命令exit退出终端窗口,再次打开终端进入到mysql的文件夹下
进入mysql:bin/mysql -uroot -p (把刚刚复制的密码粘贴上来)
[root@localhost ~]# cd /usr/local/mysql
[root@localhost mysql]# bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.17
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
11.登录后重置root密码
mysql> set password for 'root'@localhost=password('123456');
Query OK, 0 rows affected, 1 warning (0.09 sec)
1.mysql5.7.17安装在/usr/local/mysql目录里面,也可以安装在其他地方
(安装包最好与Linux系统一样,eg;32位的就是“mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz”,官网可下载)
mkdir /usr/local/mysql
2.解压并复制
tar -xvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz(我是手动解压的)
mv mysql-5.7.17-linux-glibc2.5-x86_64/* /usr/local/mysql/
3.创建data目录(很重要!)
mkdir /usr/local/mysql/data
4.创建mysql用户和修改权限
groupadd mysql
chown -R mysql.mysql /usr/local/mysql/
5.初始化数据
进入到mysql文件下:cd /usr/local/mysql
[root@localhost mysql] ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
2016-01-20 02:47:35 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2016-01-20 02:47:45 [WARNING] The bootstrap log isn't empty:
2016-01-20 02:47:45 [WARNING] 2016-01-19T18:47:36.732678Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2016-01-19T18:47:36.750527Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2016-01-19T18:47:36.750560Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
6. 复制配置文件到 /etc/my.cnf
cp -a ./support-files/my-default.cnf /etc/my.cnf (选择y)
7. mysql的服务脚本放到系统服务中
cp -a ./support-files/mysql.server /etc/init.d/mysqld
修改my.cnf文件 (vim /etc/my.cnf)
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
# server_id = .....
socket = /tmp/mysql.sock
character-set-server = utf8
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
修改完了之后再最下面输入命令 :mq
8.启动mysql
service mysqld start
ps -ef #查看是启动
9.查看初始化自动生成的密码: cat /root/.mysql_secret (记住并复制下来,等会登陆mysql需要)
10.输入命令exit退出终端窗口,再次打开终端进入到mysql的文件夹下
进入mysql:bin/mysql -uroot -p (把刚刚复制的密码粘贴上来)
[root@localhost ~]# cd /usr/local/mysql
[root@localhost mysql]# bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.17
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
11.登录后重置root密码
mysql> set password for 'root'@localhost=password('123456');
Query OK, 0 rows affected, 1 warning (0.09 sec)
阅读全文
2 0
- Linux系统上安装MYSQL数据库
- 在linux系统上安装mysql数据库
- Linux系统上安装MySQL数据库
- 在 Linux 系统上安装 MySQL 数据库服务
- LINUX 上安装Mysql数据库
- Linux上安装mysql数据库
- linux上安装mysql数据库
- Linux上Mysql数据库安装
- Linux上安装MySQL数据库
- Linux系统上安装MySQL
- Linux系统上安装mysql
- linux系统安装mysql数据库
- linux系统mysql数据库安装
- CentOS 6.5系统上安装MySQL数据库
- CentOS 6.5系统上安装MySQL数据库
- 在linux系统上安装Greenplum数据库
- Linux上Mysql数据库安装目录移动
- Linux操作系统上安装Mysql数据库
- 多线程中的ThreadLocal 详解
- spring mvc
- Java
- solr6.4.2全量与增量导入数据
- MPEG2 TS小结(五)
- Linux系统上安装MySQL数据库
- Vim常用操作快捷键记录
- ubuntu 12.04无root权限安装YouCompleteMe
- 关于各种无法解析的外部符号问题的相应解决方案
- js 非空判断
- shell中的EOF用法
- c++作业五
- 求最大利益的简单算法
- 计蒜客练习