在linux系统上构建mysql服务器
一、在官网下载mysql安装包
下图是mysql安装包的介绍
二、安装软件包
1、安装依赖# yum -y install perl-Date-Dumper perl-JSON perl-Time-HiRes2、解压mysql安装包# tar -xvf mysql-5.7.24.tar//解压mysql包3、卸载老版本的包[root@localhost ~]# rm -rf /etc/my.cnf4、删除数据[root@localhost ~]# rm -rf /var/lib/mysql/*5、卸载软件包(没有会显示未安装软件包)[root@localhost ~]# rpm -e --nodeps mariadb-server mariadb警告:/var/log/mariadb/mariadb.log 已另存为/var/log/mariadb/mariadb.log.rpmsave#yum -y remove mariadb-libs.x86_64 1:5.5.52-1.el76、yum源安装#yum -y install mysql-community-client mysql-community-common mysql-community-devel mysql-community-embedded mysql-community-embedded-compat mysql-community-embedded-develmysql-community-libs mysql-community-libs-compat mysql-community-minimal-debuginfo mysql-community-server mysql-community-test或者#yum -y install mysql-community-*.rpm7、查看安装了的mysql有关安装包# rpm -qa | grep -y mysql8、启动服务# systemctl start mysqld# systemctl enable mysqld //设置开机自启# systemctl status mysqld[root@proxy mysql]# ss -antulp | grep mysqld //查看服务启动端口# ps aux | grep mysqld //查进程三、连接数据库
1、查随机生成的root密码# grep password /var/log/mysqld.log#grep 'temporary password' /var/log/mysqld.log //随机生成的管理密码初始密码登陆mysql:
(!!!用随机生成密码登陆必须马上修改密码管理,不然会报错)
2、客户端命令mysql连接数据库# mysql -hlocalhost -uroot -p'pIhMu,i2OS#,' //用初始密码登录mysql> h //登录成功后,查可用的快捷键四、修改密码
1、只能先修密码mysql> alter user root@"localhost" identified by "123qqq...A";2、可以修改密码限制长度mysql> show variables like "%password%";//查询密码有关的变量mysql> set global validate_password_policy=0;//只验证长度mysql> set global validate_password_length=6;//修改密码长度为6位mysql> alter user root@"localhost" identified by "123456";//修改root密码为123456推荐教程:mysql教程以上就是在linux系统上构建mysql服务器的详细内容,更多请关注小潘博客其它相关文章!