时间:2021-07-01 10:21:17 帮助过:22人阅读
初始化后,会打印日志,如下 ,注意看最后输出,红色标记部分,这个就是root的临时密码。
- <span style="color: #800080">2018</span>-<span style="color: #800080">01</span>-12T05:<span style="color: #800080">08</span>:<span style="color: #800080">12</span>.048923Z <span style="color: #800080">0</span> [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please <span style="color: #0000ff">use</span> --explicit_defaults_for_timestamp server option (see doc umentation <span style="color: #0000ff">for</span><span style="color: #000000"> more details).
- </span><span style="color: #800080">2018</span>-<span style="color: #800080">01</span>-12T05:<span style="color: #800080">08</span>:<span style="color: #800080">12</span>.228535Z <span style="color: #800080">0</span> [Warning] InnoDB: New log files created, LSN=<span style="color: #800080">45790</span>
- <span style="color: #800080">2018</span>-<span style="color: #800080">01</span>-12T05:<span style="color: #800080">08</span>:<span style="color: #800080">12</span>.251370Z <span style="color: #800080">0</span><span style="color: #000000"> [Warning] InnoDB: Creating foreign key constraint system tables.
- </span><span style="color: #800080">2018</span>-<span style="color: #800080">01</span>-12T05:<span style="color: #800080">08</span>:<span style="color: #800080">12</span>.305856Z <span style="color: #800080">0</span> [Warning] No existing UUID has been found, so we a ssume that this is the first <span style="color: #0000ff">time</span> that this server has been started. Generating a new UUID: 968b7130-f756-11e7-<span style="color: #800080">8704</span>-<span style="color: #000000">000c29009e57.
- </span><span style="color: #800080">2018</span>-<span style="color: #800080">01</span>-12T05:<span style="color: #800080">08</span>:<span style="color: #800080">12</span>.306388Z <span style="color: #800080">0</span> [Warning] Gtid <span style="color: #0000ff">table</span> is <span style="color: #0000ff">not</span> ready to be used. Tabl e <span style="color: #800000">‘</span><span style="color: #800000">mysql.gtid_executed</span><span style="color: #800000">‘</span><span style="color: #000000"> cannot be opened.
- </span><span style="color: #800080">2018</span>-<span style="color: #800080">01</span>-12T05:<span style="color: #800080">08</span>:<span style="color: #800080">12</span>.307188Z <span style="color: #800080">1</span> [Note] A temporary password is generated <span style="color: #0000ff">for</span> root@localhost: <font color="#ff0000"><font size="4">LwchxXdoO5*8</font></font>
配置数据库:
- vi /etc/<span style="color: #0000ff">my</span>.cnf
my.cnf内容:
- <span style="font-weight: bold; color: #800000">[</span><span style="color: #800000">mysqld</span><span style="font-weight: bold; color: #800000">]</span><span style="color: #000000">
- #目录设置
- basedir</span>=<span style="color: #000000">/usr/local/mysql
- datadir</span>=<span style="color: #000000">/usr/local/mysql/data
- port</span>=3306<span style="color: #000000">
- #服务ID
- socket</span>=<span style="color: #000000">/tmp/mysql.sock
- #数据库表名大小写不敏感
- lower_case_table_names</span>=1<span style="color: #000000">
- #设置字符集,防止中文乱码
- init_connect</span>=‘SET collation_connection =<span style="color: #000000"> utf8_general_ci‘
- init_connect</span>=<span style="color: #000000">‘SET NAMES utf8‘
- character-set-server</span>=<span style="color: #000000">utf8
- collation-server</span>=<span style="color: #000000">utf8_general_ci
- skip-character-set-client-handshake
- </span><span style="font-weight: bold; color: #800000">[</span><span style="color: #800000">client</span><span style="font-weight: bold; color: #800000">]</span><span style="color: #000000">
- default-character-set</span>=<span style="color: #000000">utf8
- </span><span style="font-weight: bold; color: #800000">[</span><span style="color: #800000">mysql</span><span style="font-weight: bold; color: #800000">]</span><span style="color: #000000">
- default-character-set</span>=utf8
安装成服务:
- cp -a ./support-files/mysql.server /etc/init.d/mysqld
启动服务
- service mysqld start
登录到mysql
- ./bin/mysql -u root -<span style="color: #000000">p
- Enter password</span>:<span style="color: #000000">
- Welcome to the MySQL monitor</span>. Commands end with ; or \g.<span style="color: #000000">
- Your MySQL connection id is </span><span style="color: #800000">3</span><span style="color: #000000">
- Server version</span>: <span style="color: #800000">5.7</span>.<span style="color: #800000">20</span><span style="color: #000000">
- Copyright (c) </span><span style="color: #800000">2000</span>, <span style="color: #800000">2017</span>, Oracle and/or its affiliates. All rights reserved.<span style="color: #000000">
- Oracle is a registered trademark of Oracle Corporation and</span>/<span style="color: #000000">or its
- affiliates</span>.<span style="color: #000000"> Other names may be trademarks of their respective
- owners</span>.<span style="color: #000000">
- Type </span><span style="font-weight: bold; color: #000000">‘</span><span style="font-weight: bold; color: #000000">help;</span><span style="font-weight: bold; color: #000000">‘</span> or <span style="font-weight: bold; color: #000000">‘</span><span style="font-weight: bold; color: #000000">\h</span><span style="font-weight: bold; color: #000000">‘</span> <span style="color: #0000ff">for</span> help. Type <span style="font-weight: bold; color: #000000">‘</span><span style="font-weight: bold; color: #000000">\c</span><span style="font-weight: bold; color: #000000">‘</span> to clear the current input statement.<span style="color: #000000">
- mysql</span>> grant all privileges on *.* to root@<span style="font-weight: bold; color: #000000">"</span><span style="font-weight: bold; color: #000000">%</span><span style="font-weight: bold; color: #000000">"</span> identified by <span style="font-weight: bold; color: #000000">"</span><span style="font-weight: bold; color: #000000">2018dlj123!@#0112</span><span style="font-weight: bold; color: #000000">"</span><span style="color: #000000"> with grant option;
- ERROR </span><span style="color: #800000">1820</span> (HY000): <font color="#ff0000" size="3">You must reset your password using ALTER USER statement before executing this statement.</font>
一开始想做授权,结果发现报错,原因是必须要修改初始密码。
修改初始密码:
- mysql> ALTER USER USER() IDENTIFIED BY <span style="font-weight: bold; color: #000000">‘</span><span style="font-weight: bold; color: #000000">test123456</span><span style="font-weight: bold; color: #000000">‘</span>;
- Query OK, 0 rows affected (0.00 sec)
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> grant all privileges on *.* to root@"%" identified by "test123456" with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
至此安装完毕!
mysql5.7:安装教程
标签:hang cal statement 建立 create error tin 红色 cccccc