mysql-8.0.13安裝及部分操作

官網下載win64壓縮包;

我是解壓在c盤下新建的web文件中

然後打開C:\web\mysql-8.0.13-winx64,創建my.ini文件

文件內容

[client]
port = 3308
default-character-set = UTF8MB4
 
[mysqld]
port = 3308
character_set_server = UTF8MB4
 
basedir=C:\web\mysql-8.0.13-winx64
datadir=C:\web\mysql-8.0.13-winx64\data
 
group_concat_max_len=20000
 
 
[WinMySQLAdmin]
C:\web\mysql-8.0.13-winx64\bin\mysqld.exe

然後在管理員權限下的cmd中選擇進入其中的bin目錄

cd C:\web\mysql-8.0.13-winx64\bin

接着輸入

mysqld --initialize --console

出現密碼+V0x;iq!7n=F,並報了一個錯誤,不過我在之前的代碼中已經改了過來。

C:\web\mysql-8.0.13-winx64\bin>mysqld --initialize --console
2018-11-30T03:44:42.553357Z 0 [System] [MY-013169] [Server] C:\web\mysql-8.0.13-winx64\bin\mysqld.exe (mysqld 8.0.13) initializing of server in progress as process 60624
2018-11-30T03:44:42.555732Z 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.
2018-11-30T03:44:46.075302Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: +V0x;iq!7n=F
2018-11-30T03:44:47.177814Z 0 [System] [MY-013170] [Server] C:\web\mysql-8.0.13-winx64\bin\mysqld.exe (mysqld 8.0.13) initializing of server has completed

然後是創建服務器和創建用戶

C:\web\mysql-8.0.13-winx64\bin>mysqld --install MySQL8.0 #安裝服務
Service successfully installed.

C:\web\mysql-8.0.13-winx64\bin>net start MySQL8.0 #開始服務,服務器名MySQL8.0
MySQL8.0 服務正在啓動 .
MySQL8.0 服務已經啓動成功。

C:\web\mysql-8.0.13-winx64\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.13

Copyright (c) 2000, 2018, 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> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.01 sec)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '*******';
Query OK, 0 rows affected (0.09 sec)

mysql> CREATE USER 'ghfuidy'@'%' IDENTIFIED WITH mysql_native_password BY '*******';
Query OK, 0 rows affected (0.01 sec)

#顯示所有數據庫
mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.02 sec)

#使用數據庫
mysql> user information_schema;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'user information_schema' at line 1
mysql> show tables
    -> ;
ERROR 1046 (3D000): No database selected
mysql> use mysql
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| component                 |
| db                        |
| default_roles             |
| engine_cost               |
| func                      |
| general_log               |
| global_grants             |
| gtid_executed             |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| innodb_index_stats        |
| innodb_table_stats        |
| password_history          |
| plugin                    |
| procs_priv                |
| proxies_priv              |
| role_edges                |
| server_cost               |
| servers                   |
| slave_master_info         |
| slave_relay_log_info      |
| slave_worker_info         |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
33 rows in set (0.01 sec)

#查看所有用戶狀態
mysql> select host,user from mysql.user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| %         | ghfuidy          |
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
| localhost | root             |
+-----------+------------------+
5 rows in set (0.00 sec)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章