博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql 安装
阅读量:5054 次
发布时间:2019-06-12

本文共 4709 字,大约阅读时间需要 15 分钟。

这里使用的mysql是 mysql-5.7.16

将下载下来的mysql 安装tar包下载解压这就不用多说了,

 ps:(mysql-5.7.16-linux-glibc2.5-x86_64 这名字太长了,我把他改为mysql-5.7.16)

首先

(1)配置环境变量

############mysql#############export PATH=$PATH:/usr/local/development/mysql/mysql-5.7.16/bin

(2)新增mysql的用户和组

[root@node1 development]# groupadd mysql[root@node1 development]# useradd -r -g mysql mysql //修改mysql的目录权限[root@node1 development]# chown -R mysql mysql /usr/local/development/mysql/mysql-5.7.16/

(3)修改mysql安装目录中的   support-files/mysql.server 文件,设置mysql的安装目录 和 mysql的数据存储目录

# If you want to affect other MySQL variables, you should make your changes# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.# If you change base dir, you must also change datadir. These may get# overwritten by settings in the MySQL configuration files.//mysql的安装目录basedir=/usr/local/development/mysql/mysql-5.7.16 //mysql的数据存储目录datadir=/usr/local/development/mysql/mysqlData

(4)初始化数据库

[root@node1 bin]# ./mysql_install_db --user=mysql --basedir=/usr/local/development/mysql/mysql-5.7.16 --datadir=/usr/local/development/mysql/mysqlData 2017-06-05 17:44:50 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize2017-06-05 17:44:55 [WARNING] The bootstrap log isn't empty:2017-06-05 17:44:55 [WARNING] 2017-06-05T09:44:51.057443Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead2017-06-05T09:44:51.075095Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)2017-06-05T09:44:51.075137Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)

我们的MySQL存储目录已经生成数据了

(5)启动MySQL(发现报错)

[root@node1 support-files]# ./mysql.server startStarting MySQL.touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directorychmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directorytouch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directorychown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory/usr/local/development/mysql/mysql-5.7.16/bin/mysqld_safe: line 135: /var/log/mariadb/mariadb.log: No such file or directory/usr/local/development/mysql/mysql-5.7.16/bin/mysqld_safe: line 169: /var/log/mariadb/mariadb.log: No such file or directorytouch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directorychown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directorychmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory/usr/local/development/mysql/mysql-5.7.16/bin/mysqld_safe: line 135: /var/log/mariadb/mariadb.log: No such file or directory ERROR! The server quit without updating PID file (/usr/local/development/mysql/mysqlData/node1.pid).

我们确实是没有/var/log/mariadb/mariadb.log 这个目录,这个是因为你没有指定他的配置文件的话,他会默认找到/etc/my.cnf 这个配置文件,因为我们修改了mysql的数据存储目录。

将/etc/my.cnf 删掉,再次启动

[root@node1 support-files]# rm -f /etc/my.cnf[root@node1 support-files]# ./mysql.server startStarting MySQL.. SUCCESS!

(6)查询MySQL自动生成的root密码

[root@node1 support-files]# more /root/.mysql_secret # Password set for user 'root@localhost' at 2017-06-05 17:44:50 N5*gFyur1LbC                          //这里就是

(7)在bin目录下 登录MySQL(将自动生成的密码粘贴上去即可)

[root@node1 bin]# ./mysql -uroot -pEnter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.16Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

(8)修改MySQL的root密码(你肯定不想使用自动生成的那个密码吧)

mysql> set password=password('mysql123');//设置密码Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> alter user 'root'@'localhost' password expire never//将密码应用于root用户    -> ;Query OK, 0 rows affected (0.00 sec)mysql> flush privileges//刷新权限的列表    -> ;Query OK, 0 rows affected (0.00 sec)mysql> exit//退出Bye

重新登录,试一试刚才修改的密码是否生效,当然你们是看不见输入密码的,我这里已经生效了

上面是MySQL的搭建过程,我是使用MySQL来存储hive的元数据,而MySQL不允许使用root用户远程登录,所以我新建hive用户

mysql> create user 'hive'@'%' identified by 'hive123';//创建用户名和密码Query OK, 0 rows affected (0.00 sec)mysql> grant all on *.* to 'hive'@'%';//赋予hive用户所有权限,'%'表示任何地址都可以通过hive用户连接mysql,如果你想限制可以加入你的ipQuery OK, 0 rows affected (0.00 sec)mysql> flush privileges;//刷新权限列表Query OK, 0 rows affected (0.00 sec)mysql> create database hivedb;//创建数据库
Query OK, 1 row affected (0.00 sec)

查看创建的数据库

mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || hivedb             || mysql              || performance_schema || sys                |+--------------------+

 

转载于:https://www.cnblogs.com/zhangXingSheng/p/6941422.html

你可能感兴趣的文章
平均分和最高分
查看>>
Java-并发整理
查看>>
【转】java编译错误 程序包javax.servlet不存在javax.servlet.*
查看>>
[笔记]C#基础入门(十八)——C#中多重if结构
查看>>
Failed to write genesis block: database already contains an incompatible
查看>>
node——模块分类,require执行顺序,require注意事项,原理
查看>>
回发或回调参数无效的各种情况分析及解决办法
查看>>
第14周总结
查看>>
tomcat访问
查看>>
取消元件库里的元件等比例缩放
查看>>
unity中使用代理(翻译)
查看>>
openWRT自学---初始化过程和主要脚本的分析--转
查看>>
planning algorithms chapter 3
查看>>
HDU 1166 敌兵布阵 树状数组
查看>>
基于第三方开源库的OPC服务器开发指南(1)——OPC与DCOM
查看>>
PHP重要知识点
查看>>
伪静态例子与APACHE伪静态配置
查看>>
把ISO文件加载到虚拟光驱
查看>>
[区块链] 密码学——椭圆曲线密码算法(ECC)
查看>>
第6周学习进度
查看>>