溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

mysql community server 8.0.12如何安裝配置

發(fā)布時(shí)間:2021-07-29 11:09:17 來(lái)源:億速云 閱讀:174 作者:小新 欄目:MySQL數(shù)據(jù)庫(kù)

這篇文章將為大家詳細(xì)講解有關(guān)mysql community server 8.0.12如何安裝配置,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

下載

本例為:MySQL Community Server 8.0.12。

解壓

解壓至安裝目錄,比如 D 盤根目錄下。

本例為:D:\mysql-8.0.12-winx64。

創(chuàng)建 my.ini

my.ini 是 MySQL 安裝的配置文件:

[mysqld]
# 安裝目錄
basedir=D:\\mysql-8.0.12-winx64
# 數(shù)據(jù)存放目錄
datadir=D:\\mysqlData\\data

my.ini放置在 MySQL 安裝目錄的根目錄下。需要注意的是,要先創(chuàng)建D:\mysqlData目錄。data目錄是由 MySQL 來(lái)創(chuàng)建。

初始化安裝

執(zhí)行:

mysqld --defaults-file=D:\mysql-8.0.12-winx64\my.ini --initialize --console

控制臺(tái)輸出如下,說(shuō)明安裝成功:

>mysqld --defaults-file=D:\mysql-8.0.12-winx64\my.ini --initialize --console
2018-08-20T16:14:45.287448Z 0 [System] [MY-013169] [Server] D:\mysql-8.0.12-winx64\bin\mysqld.exe (mysqld 8.0.12) initializing of server in progress as process 5012
2018-08-20T16:14:45.289628Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2018-08-20T16:14:45.299329Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-08-20T16:14:45.301316Z 0 [System] [MY-010910] [Server] D:\mysql-8.0.12-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.12) MySQL Community Server - GPL.

D:\mysql-8.0.12-winx64\bin>mysqld --defaults-file=D:\mysql-8.0.12-winx64\my.ini --initialize --console
2018-08-20T16:15:25.729771Z 0 [System] [MY-013169] [Server] D:\mysql-8.0.12-winx64\bin\mysqld.exe (mysqld 8.0.12) initializing of server in progress as process 18148
2018-08-20T16:15:43.569562Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: L-hk!rBuk9-.
2018-08-20T16:15:55.811470Z 0 [System] [MY-013170] [Server] D:\mysql-8.0.12-winx64\bin\mysqld.exe (mysqld 8.0.12) initializing of server has completed

其中,“L-hk!rBuk9-.”就是 root 用戶的初始化密碼。稍后可以做更改。

啟動(dòng)、關(guān)閉 MySQL server

執(zhí)行mysqld就能啟動(dòng) MySQL server,或者執(zhí)行 mysqld –console可以看到完整的啟動(dòng)信息:

>mysqld --console
2018-08-20T16:18:23.698153Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2018-08-20T16:18:23.698248Z 0 [System] [MY-010116] [Server] D:\mysql-8.0.12-winx64\bin\mysqld.exe (mysqld 8.0.12) starting as process 16304
2018-08-20T16:18:27.624422Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2018-08-20T16:18:27.793310Z 0 [System] [MY-010931] [Server] D:\mysql-8.0.12-winx64\bin\mysqld.exe: ready for connections. Version: '8.0.12' socket: '' port: 3306 MySQL Community Server - GPL.

關(guān)閉,可以執(zhí)行 mysqladmin -u root shutdown。

使用 MySQL 客戶端

使用 mysql 來(lái)登錄,賬號(hào)為 root,密碼為“L-hk!rBuk9-.”:

>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.12

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.

執(zhí)行下面的語(yǔ)句來(lái)改密碼。其中“123456”即為新密碼。

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.13 sec)

MySQL 常用指令

顯示已有的數(shù)據(jù)庫(kù):

mysql> show databases;
+--------------------+
| Database  |
+--------------------+
| information_schema |
| mysql  |
| performance_schema |
| sys  |
+--------------------+
4 rows in set (0.08 sec)

創(chuàng)建新的數(shù)據(jù)庫(kù):

mysql> CREATE DATABASE lite;
Query OK, 1 row affected (0.19 sec)

使用數(shù)據(jù)庫(kù):

mysql> USE lite;
Database changed

建表:

建表執(zhí)行:

mysql> CREATE TABLE t_user (user_id BIGINT NOT NULL, username VARCHAR(20));
Query OK, 0 rows affected (0.82 sec)

查看表:

查看數(shù)據(jù)庫(kù)中的所有表:

mysql> SHOW TABLES;
+----------------+
| Tables_in_lite |
+----------------+
| t_user  |
+----------------+
1 row in set (0.00 sec)

查看表的詳情:

mysql> DESCRIBE t_user;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| user_id | bigint(20) | NO | | NULL | |
| username | varchar(20) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

插入數(shù)據(jù):

mysql> INSERT INTO t_user(user_id, username) VALUES(1, '老衛(wèi)');
Query OK, 1 row affected (0.08 sec)

關(guān)于“mysql community server 8.0.12如何安裝配置”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI