
XAMPP の MySQL(MariaDB)にパスワードを設定する
公開日:2019年06月22日
更新日:2019年06月22日
シェル(コマンドプロンプト)を起動
- XAMPPのコントロールパネルからMySQL(MariaDB)を起動します
- MySQL(MariaDB)が起動していることを確認します
- 「Shell」ボタンをクリックしてシェル(コマンドプロンプト)を起動します
rootユーザでMySQL(MariaDB)にログイン
シェルに以下を記述して「Enter」を押し、MySQL(MariaDB)へログインして命令待ち状態にします。
mysql -u root
カーソルが点滅している行の行頭が以下になっていれば、MySQL(MariaDB)の命令待ち状態です。
MariaDB [(none)]>
MySQL(MariaDB)にパスワード設定
以下の命令を使ってrootユーザにパスワードを設定します。
「ここにパスワードを記述」部分を設定するパスワードに変更し「Enter」を押して命令を確定させます。
update mysql.user set password=password(‘ここにパスワードを記述’) where user = ‘root’;
変更内容を以下の命令で反映させます。
flush privileges;
最後にMySQLを一度ログアウトします。
今までの内容は以下です。
# mysql -u root Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 10.1.29-MariaDB mariadb.org binary distribution Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> update mysql.user set password=password('admin') where user = 'root'; Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0 MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit; Bye
パスワードを使用してMySQL(MariaDB)にログイン
シェル(コマンドプロンプト)に以下の命令を入力し「Enter」を押します。
mysql -u root -p
パスワードを聞かれるので、先程設定したパスワードを入力し「Enter」を押します。
Enter password:
「Welcome to the MariaDB monitor.」が表示され、カーソルが点滅している行の行頭が以下になっていれば、パスワード設定完了です。
MariaDB [(none)]>
今までの内容は以下です。
# mysql -u root -p Enter password: *************** Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 4 Server version: 10.1.29-MariaDB mariadb.org binary distribution Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
同じカテゴリーのコンテンツ