美文网首页
MySQL Server配置安装

MySQL Server配置安装

作者: 火卫控 | 来源:发表于2022-04-23 14:48 被阅读0次

    由于网站需要动态网页,需要LAMP组合
    Linux + Apache + MySQL + PHP
    由于正在WIN10系统上学习LAMP,先安装WIN10上的MySQL

    mysql server配置安装

    1. 下载MySQL server Win64文件包
    2. 配置 my.ini 文件
    3. 初始化安装mysql
    4. 连接MySQL

    1. 下载MySQL server Win64文件包

    MySQL官网下载地址
    这里下载的是8.0.28最新版本

    下载社区服务版本就可以了

    2. 配置 my.ini 文件

    新建一个 my.ini 文件,配置好
    端口为3306
    basedir=D:\\ruanjian\\mysql8为MySQL安装的地址
    具体配置内容如下:

    [client]
    # 设置mysql客户端默认字符集
    default-character-set=utf8
     
    [mysqld]
    # 设置3306端口
    port = 3306
    # 设置mysql的安装目录
    basedir=D:\\ruanjian\\mysql8
    # 设置 mysql数据库的数据的存放目录,MySQL 8+ 不需要以下配置,系统自己生成即可,否则有可能报错
    # datadir=C:\\web\\sqldata
    # 允许最大连接数
    max_connections=20
    # 服务端使用的字符集默认为8比特编码的latin1字符集
    character-set-server=utf8
    # 创建新表时将使用的默认存储引擎
    default-storage-engine=INNODB
    

    3. 初始化安装mysql

    首先要采用管理员权限打开cmd
    切换到安装目录的bin文件夹下面
    依次输入运行如下指令:
    mysqld --initialize --console
    net start mysql
    mysql -u root -p
    \q为退出

    D:\ruanjian\mysql8\mysql8.0.28\bin>mysqld --initialize --console
    2022-04-23T05:41:36.329519Z 0 [System] [MY-013169] [Server] D:\ruanjian\mysql8\mysql8.0.28\bin\mysqld.exe (mysqld 8.0.28) initializing of server in progress as process 6616
    2022-04-23T05:41:36.329620Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file 'D:\ruanjian\mysql8\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
    2022-04-23T05:41:36.330344Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
    2022-04-23T05:41:36.745248Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
    2022-04-23T05:41:40.714646Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
    2022-04-23T05:41:44.815840Z 0 [Warning] [MY-013829] [Server] Missing data directory for ICU regular expressions: D:\ruanjian\mysql8\lib\private\.
    2022-04-23T05:41:45.517682Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: viSBj(gVu2Id
    
    D:\ruanjian\mysql8\mysql8.0.28\bin>mysqld install
    Service successfully installed.
    
    D:\ruanjian\mysql8\mysql8.0.28\bin>net start mysql
    MySQL 服务正在启动 .
    MySQL 服务已经启动成功。
    
    
    D:\ruanjian\mysql8\mysql8.0.28\bin>mysql -u root -p
    Enter password: ************
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 8
    Server version: 8.0.28
    
    Copyright (c) 2000, 2022, Oracle and/or its affiliates.
    
    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> \q
    Bye
    

    4. 连接MySQL

    采用Navicat for MySQL 软件,连接
    连接名随便填
    由于MySQL8改变了密码方式,需要现在MySQL环境下运行如下指令:
    先连接MySQL数据库
    mysql -u root -p
    再改变密码方式
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
    再更改初始化密码
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'aqy0716';
    具体代码如下:

    D:\ruanjian\mysql8\mysql8.0.28\bin>mysql -u root -p
    Enter password: ************
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 9
    Server version: 8.0.28
    
    Copyright (c) 2000, 2022, Oracle and/or its affiliates.
    
    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> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
    Query OK, 0 rows affected (0.21 sec)
    
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'aqy0716';
    Query OK, 0 rows affected (0.19 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.16 sec)
    
    Navicat for MySQL

    连接成功后,会发现用户下已经有四个数据库了是系统默认的,不能删除
    然后新建数据库boke和artical,如下图:


    新建数据库boke和artical

    参考:
    MySQL的安装与配置——详细教程

    相关文章

      网友评论

          本文标题:MySQL Server配置安装

          本文链接:https://www.haomeiwen.com/subject/pjsaertx.html