Ubuntu18.04の下にMySQLをインストールします

注意:以下の操作はroot権限で実行されます。

MySQLをそこにインストールする場合#参照してください。

dpkgの-l | grepのmysqlの

#MySQLをインストールします。

aptインストールのMySQLサーバ

14733211-6197c3897ccc6c0d.png

インストールが完了したら、インストールが成功したかどうかを確認するには、次のコマンドを使用することができます。

netstatのタップの| grepのmysqlの

LISTEN状態でのMySQLのソケットが正常にインストールされたことを示している場合、上記のコマンドによる検査の後、あなたが参照してください。

14733211-ec7f95f1daabbe42.png

以下のコマンドを使用してMySQLデータベースをログ:

MySQLの-uルート-p

着陸の選択を示す-uユーザ名、-pは、ユーザーのパスワードを表し、今パスワードを入力し、パスワードなしでMySQLのデータベースです:直接入力では、MySQLデータベースを入力することができます。

その後、データベースを表示し、あなたはすべての現在のデータベースを表示することができます。

14733211-d438a26f05c07a7b.png

次に、データベース、データベースの初期化の安全性と正常な動作を保証するためです。この初期化動作は、次の5つのステップを含みます。

(1)インストール検証パスワードプラグイン。

(2)ルート独自のデータベース管理者パスワードを設定してください。

(3)その後、匿名アカウントを削除し、データベースのビジネス上の操作の安全性を確保するために、リモート・データベース管理者からrootでログインします。

(4)デフォルトのテストデータベースを削除し、データベースへのテストアクセス一連のキャンセル。

(5)の許可リストを更新するには、初期設定は直ちに有効になりましょう。

上述のデータベースの初期化手順については、I以下の次の出力は、簡単なコメントをしました。

ルート@ Ubuntuの仮想マシン:〜#のmysql_secure_installation

MySQLサーバの展開を確保。

空白のパスワードを使用してMySQLに接続します。

PASSWORDプラグインを検証し、パスワードをテストするために使用することができます

およびセキュリティを向上させます。これは、パスワードの強度をチェックします

and allows the users to set only those passwords which are

secure enough. Would you like to setup VALIDATE PASSWORD plugin? #要安装验证密码插件吗?

Press y|Y for Yes, any other key for No: N # 这里我选择N

Please set the password for root here.

New password:# 输入要为root管理员设置的数据库密码

Re-enter new password:# 再次输入密码

By default, a MySQL installation has an anonymous user,

allowing anyone to log into MySQL without having to have

a user account created for them. This is intended only for

testing, and to make the installation go a bit smoother.

You should remove them before moving into a production

environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y  # 删除匿名账户

Success.

Normally, root should only be allowed to connect from

'localhost'. This ensures that someone cannot guess at

the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N # 禁止root管理员从远程登录,这里我没有禁止

... skipping.

By default, MySQL comes with a database named 'test' that

anyone can access. This is also intended only for testing,

and should be removed before moving into a production

environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y  # 删除test数据库并取消对它的访问权限

- Dropping test database...

Success.

- Removing privileges on test database...

Success.

Reloading the privilege tables will ensure that all changes

made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y  # 刷新授权表,让初始化后的设定立即生效

Success.

All done!

14733211-3dd53fe3cca5518b.png

检查mysql服务状态:

systemctl status mysql

显示如下结果说明mysql服务运行是正常的:

14733211-c9ff9d6bb3aae140.png

再次用mysql -u root -p命令,Enter password:处输入刚设置的密码,回车,就能够进入mysql数据库。

使用のmysqlを使用して、コマンドをという名前のデータベースMySQLを開くには、データベース内の現在のテーブルを表示します。showテーブルを、ユーザーのクエリデータテーブル:ユーザから選択*;(ユーザーアカウント情報テーブルは、すべてのMySQLデータベースです)

14733211-700a7dc8c90bcc95.png

MySQLのは、現在のリモートアクセス、コンフィギュレーション・ファイル/etc/mysql/mysql.conf.d/mysqld.cnf最初の編集を許可するように設定されています。

vimの/etc/mysql/mysql.conf.d/mysqld.cnf

バインドアドレス= 127.0.0.1をコメントアウト

14733211-008f3c7c8a90a01a.png

authorizationコマンドを実行し、保存して終了した後、mysqlデータベースを入力します。

MySQLの-uルート-p

。MySQLは> grantオプションで「パスワード」によって識別される「%」@ * * rootにすべてに付与。

MySQLの>フラッシュ権限;#リフレッシュ許可

MySQLの>終了

次に、以下のコマンドを実行し、exitコマンドのMySQLサービスを実行して、MySQLを再起動します。

systemctl再起動のMySQL

ます。https://www.jianshu.com/p/b54ed11f021fで再現

おすすめ

転載: blog.csdn.net/weixin_34301132/article/details/91323436