MySQL 基本配置 | 珊瑚贝

主要亮点为配置和密码找回,安装什么的就。。。

MySQL 基本配置

官网地址:www.mysql.com 安装可参考:https://cuiqingcai.com/5200.html

window:

注意终端 mysqld 开启的不能关闭!

1
2
mysqld //启动服务
mysql //启动客户端

制作服务:

  1. 关闭进程
1
2
3
4
// 查找任务进程
tasklist |findstr mysqld
//终止任务进程
taskkill /F /PID PID
  1. 安装服务与移除服务
1
2
3
4
//安装服务
mysqld --install
//移除服务
mysqld --remove

Linux:

1
2
3
4
centos:
yum -y install mariadb-server mariadb
ubuntu:
yum -y install mysqld-server msyql-client

基本使用: // 查看所有的数据库 show databases; // 进入对应的库: use database(name) 查看表: select * from db;

配置环境变量:

1
vim /etc/profile

在文档最后一行加入:

1
2
3
4
5
PATH = /。。。:$PATH
export PATH
保存退出即可
然后在终端输入
source /etc/profile //生效

管理员密码设置与找回:

管理员账号登录 (没有密码,直接回车进入。)

1
mysql -uroot -p

设置管理员密码

1
2
3
mysqladmin -uroot -p {oldPassworld(原始密码,默认为“”,空)} password {“newpassoworld”};
mysqladmin -uroot -p password {“passoworld”};
# passoworld为你锁需要设置的密码哦

MySQL 密码找回:

密码验证思路:mysql 必定将管理员账号密码存储在某个文件夹内,使用时与输入密码验证,成功则能够连接,否则连接失败。 密码找回思路: 跳过 MySQL 密码的验证直接进入

  1. 停止 mysql 服务(注:需要终端的管理员权限运行)

    // windows:

查询进程,并找到 PID:

  1. tasklist | findsrt mysqld
    
    1
    2
    3
    4
    5
       
    2. kill掉mysql进程,否则是停止不了服务的,无论如何都需要kill掉:

    ![](https://qiniu.cuiqingcai.com/wp-content/uploads/2020/06/change_password1.png)

    #此处的为上面查询到的PID,每次都是不一样的,所以就不写具体值了 taskkill /F /PID PID

    1

    net stop mysql

    1
    2
    3
    4

    // Linux/mac:命令不同,基本思路相同 systemctl stop mysql(centos中默认的mysql是mariadb,可将mysql替换成mariadb即可)

    若安装了mysqld(mysql服务)需停止MySQL的进程服务 ,若没有安装mysql的服务则此步可省略 重新启动mysql服务,且跳过授权表

    Windows: //启动不起来,可能需要net start mysql(这个是特殊情况) mysqld --skip-grant-tables //Linux/mac: mysqld ——safe --skip-grant-tables

    1
    2
    3
    4
    5
    6

    登录,重新修改密码

    > // 登录(此时MySQL的root权限是没有密码的,直接回车即可进入) mysql -uroot -p // 修改密码(在连接数据库状态中): update mysql.user set password=password("yourpassword") where user="uroot" and host="localhost"
    >
    >

    此语句是告诉数据库,更新密码。密码为yourpassword where 为限制条件 ,限制user为root,host为localhost MySQL的关于用户授权表是存放在mysql库user表中的

    1
    2
    3

    刷新保存设置(这个一定需要,要不之前的功夫都白费了)

    flush privileges;

    1
    2
    3

    退出:

    q # 或者 exit

    1
    2
    3
    4
    5
    6
    7
    8
    9

    重启启动mysql服务(终端中): 安装了MySQL服务的:net start mysql 若没有安装则在cmd中mysqld启动一些,用另外的一个cmd连接即可

    ## 字符编码:

    查看字符编码

    登录进入mysql后

    \\s

进入 mysql 文件夹(这个可不设置,当然设置最好。): 字符编码配置默认文件:my-default.ini 新建后缀名为:’.ini‘的文件

[mysqld] character-set-server=utf8 collation-server=urf8_general_ci [client] default-character=utf8 [mysql] default-character=utf8 user =”root” password =”123456”

来源:https://cuiqingcai.com/9456.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_11551.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?