MySQL、LinuxCentos7をインストールします
公式のMysqlYumリポジトリをダウンロードしてインストールします
[root @ localhost〜] #wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
wgetがインストールされていないというプロンプトが表示された場合は、次のコマンドを実行し
yum install wget -y
て、インストールが完了するのを待ちます
次のコマンドを使用して、Yumリポジトリを直接インストールします
[root @ localhost〜] #yum -y install mysql57-community-release-el7-10.noarch.rpm
Mysqlサーバーをインストールします
[root @ localhost〜] #yum -y install mysql-community-server
Mysqlデータベース設定
-
mysqlを起動します
[root @ localhost〜] #systemctl start mysqld.service
-
Mysqlの実行ステータスを表示する
[root @ localhost〜] #systemctl status mysqld.service
-
mysqlが開始されました。mysqlのパスワードを確認してログインしてください。
[root @ localhost〜]#
grep "password" /var/log/mysqld.log
図中の丸で囲んだところが初期パスワードです
-
mysqlにログインします
[root @ localhost〜] #mysql -uroot -p
ログインパスワードが間違っている可能性があります。パスワードなしでログインするには、次のブログを参照して
くださいhttps://blog.csdn.net/qq_37671523/article/details/102160714 -
パスワードを変更します(この手順に厳密に従ってください。そうしないと失敗します!!!)
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
-
リモートアクセスを有効にする
#任意のホスト
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
#Refreshパーミッション
mysql>フラッシュ権限;
#Exit Mysql
mysql> exit; -
Yumリポジトリをアンインストールします
[root @ localhost〜] #yum -y removemysql57-community-release-el7-10.noarch
MySQLが中国語をサポートするには、文字セットをUTF-8に変更する必要があります。方法は次のとおりです。
# vim /etc/my.cnf
次のように変更します
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[client]
port=3306
socket=/var/lib/mysql/mysql.sock
default-character-set=utf8
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
character-set-server=utf8
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
mysqlサービスを再起動します
# service mysqld restart
その後、仮想マシンを再起動します。
上記の操作を実行すると、自分のコンピュータの仮想マシンでmysqlへのリモート接続が発生する場合もあります。仮想マシンがポート3306を開かないことが原因である可能性があります。方法については、次のブログhttps:// blogを参照してください
。 csdn.net/zsp151296 / article / details / 89364738