Linux: 安装mysql和设置密码登录

以yum命令安装mysql5版本为例

步骤一: 先安装wget命令 

yum -y install wget

步骤二: 下载mysql的repo源

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 

步骤三: 安装mysql的 noarch.rpm包

rpm -ivh mysql-community-release-el7-5.noarch.rpm

步骤四: 安装mysql

yum install mysql-server

 开启mysql服务:

service mysql start

设置mysql的root密码:

1. 先进入到bin目录命令是:

cd /usr/bin

2. 设置你的密码,命令是:    (其中 *** 代表的就是你想设置的密码)

mysqladmin -u root password ***

 使用密码登录mysql:(其中 *** 代表的就是刚才设置的密码)

mysql -u root -p***

登录成功后大概显示以下界面:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.6.51 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, 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.

mysql> 

接着,输入exit可以退出数据库:

exit

最后,关闭mysql服务:

service mysql stop


版权声明:本文为m0_55435847原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。