zoukankan      html  css  js  c++  java
  • 打赏 jQuery火箭图标返回顶部代码</h1> <div style="border: 1px solid #dfdfdf;border-top:none;"></div> <div style=" height: 200px; overflow:hidden;"> <span class="pre-scrollable"><div id="cnblogs_post_body" class="blogpost-body"> <h2><span style="font-family: 宋体">MySQl介绍</span></h2> <p>官方站点:<a href="http://www.mysql.com/" target="_blank">http://www.mysql.com/</a> </p> <p>MySQL是一个开放源码的小型关联式数据库管理系统。目前MySQL被广泛地应用在Internet上的中小型网站中。由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,许多中小型网站为了降低网站总体拥有成本而选择了MySQL作为网站数据库。</p> <p>MySQl数据库分类</p> <p>1)社区版</p> <p>2)商业版</p> <p>3)cluster集群</p> <h2><span style="font-family: 宋体">一.安装简介</span></h2> <h4><span style="font-family: 宋体">1)创建mysql用户的账号</span></h4> <p><span style="font-family: 宋体">首先以root身份登录到Linux系统中,然后执行如下命令创建mysql组及用户账号:</span></p> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none">1</span> [root@king ~<span style="color: rgba(0, 0, 0, 1)">]# groupadd mysql </span><span style="color: rgba(0, 128, 128, 1);user-select:none">2</span> [root@king ~]# useradd -s /sbin/nologin -g mysql -M mysql</span></pre> </div> <table id="1" style="border: 0 solid rgba(34, 220, 57, 1); background-color: rgba(210, 218, 218, 1); height: 111px; 1086px" border="0" cellspacing="1"> <tbody> <tr><th><span style="font-family: 宋体">useradd命令的参数简要说明</span></th></tr> <tr> <td><span style="font-family: 宋体">    -s/sbin/nologin表示禁止该用户登录,只需要角色存在即可,加强安全。</span></td> </tr> <tr> <td><span style="font-family: 宋体">    -g mysql指定mysql用户属于mysql组。</span></td> </tr> <tr> <td><span style="font-family: 宋体">    -M表示不创建用户家目录,因为没有需要。</span></td> </tr> <tr> <td><span style="font-family: 宋体">    groupadd和useradd这两条命令也可以用useradd-s/sbin/nologin-M mysql替代。</span></td> </tr> </tbody> </table> <p><span style="font-family: 宋体">然后检查刚刚创建的mysql用户和组,如下:</span></p> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none">1</span> [root@king ~]# tail -<span style="color: rgba(128, 0, 128, 1)">1</span> /etc/<span style="color: rgba(0, 0, 0, 1)">passwd </span><span style="color: rgba(0, 128, 128, 1);user-select:none">2</span> mysql:x:<span style="color: rgba(128, 0, 128, 1)">501</span>:<span style="color: rgba(128, 0, 128, 1)">501</span>::/home/mysql:/sbin/<span style="color: rgba(0, 0, 0, 1)">nologin </span><span style="color: rgba(0, 128, 128, 1);user-select:none">3</span> [root@king ~<span style="color: rgba(0, 0, 0, 1)">]# id mysql </span><span style="color: rgba(0, 128, 128, 1);user-select:none">4</span> uid=<span style="color: rgba(128, 0, 128, 1)">501</span>(mysql)gid=<span style="color: rgba(128, 0, 128, 1)">501</span>(mysql)组=<span style="color: rgba(128, 0, 128, 1)">501</span>(mysql)</span></pre> </div> <p><span style="font-family: 宋体">现在建立一个存放所有安装软件的固定目录,如下:</span></p> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none">1</span> [root@king ~]# mkdir -p /home/king/<span style="color: rgba(0, 0, 0, 1)">tools </span><span style="color: rgba(0, 128, 128, 1);user-select:none">2</span> [root@king ~]# cd /home/king/tools/</span></pre> </div> <h2><span style="font-family: 宋体">二.获取MySQL软件包</span></h2> <p><span style="font-family: 宋体">1.MySQL软件包的下载地址为: <a title="mysql下载教程" target="_blank">https://dev.mysql.com/</a> ,<a href="https://www.cnblogs.com/liang-io/p/9492371.html" target="_blank">官网下载示例点我</a>,</span></p> <p><span style="font-family: 宋体">2.现在以rz命令从本地安装来演示部署过程,执行时如提示无rz命令,可先执行yum install lrzsz-y安装,如下:</span></p> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none">1</span> [root@king tools]# cd /home/oldboy/tools/ <span style="color: rgba(0, 128, 128, 1);user-select:none">2</span> <span style="color: rgba(0, 0, 0, 1)">[root@king tools]# rz </span><span style="color: rgba(0, 128, 128, 1);user-select:none">3</span> rz waiting to receive.开始zmodem传输。按Ctrl+C取消正在传输mysql-<span style="color: rgba(128, 0, 128, 1)">5.5</span>.<span style="color: rgba(128, 0, 128, 1)">32</span>-linux2.<span style="color: rgba(128, 0, 128, 1)">6</span>-<span style="color: rgba(0, 0, 0, 1)">x86_64.tar.gz... </span><span style="color: rgba(0, 128, 128, 1);user-select:none">4</span> <span style="color: rgba(128, 0, 128, 1)">100</span>% <span style="color: rgba(128, 0, 128, 1)">182346</span> KB <span style="color: rgba(128, 0, 128, 1)">5525</span> KB/s <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">11</span> <span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)"> 错误 </span><span style="color: rgba(0, 128, 128, 1);user-select:none">5</span> [root@king tools]# ls -sh mysql-<span style="color: rgba(128, 0, 128, 1)">5.5</span>.<span style="color: rgba(128, 0, 128, 1)">32</span>-linux2.<span style="color: rgba(128, 0, 128, 1)">6</span>-<span style="color: rgba(0, 0, 0, 1)">x86_64.tar.gz </span><span style="color: rgba(0, 128, 128, 1);user-select:none">6</span> 179M mysql-<span style="color: rgba(128, 0, 128, 1)">5.5</span>.<span style="color: rgba(128, 0, 128, 1)">32</span>-linux2.<span style="color: rgba(128, 0, 128, 1)">6</span>-x86_64.tar.gz</span></pre> </div> <div class="msg-text normal-text"> <div class="origin-content"><span style="font-family: 宋体">三 采用二进制方式安装MySQL</span><br><span style="font-family: 宋体">(1)解压并移动MySQL二进制软件包到指定的安装路径,命令如下:</span></div> <div class="origin-content"> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none">1</span> [root@king tools]# tar xf mysql-<span style="color: rgba(128, 0, 128, 1)">5.7</span>.<span style="color: rgba(128, 0, 128, 1)">32</span>-linux2.<span style="color: rgba(128, 0, 128, 1)">6</span>-<span style="color: rgba(0, 0, 0, 1)">x86_64.tar.gz </span><span style="color: rgba(0, 128, 128, 1);user-select:none">2</span> #<==<span style="color: rgba(0, 0, 0, 1)">解压 </span><span style="color: rgba(0, 128, 128, 1);user-select:none">3</span> [root@king tools]# mkdir -p /application/ #<==<span style="color: rgba(0, 0, 0, 1)">创建安装目录,如果有就不用创建了 </span><span style="color: rgba(0, 128, 128, 1);user-select:none">4</span> [root@king tools]# mv mysql-<span style="color: rgba(128, 0, 128, 1)">5.7</span>.<span style="color: rgba(128, 0, 128, 1)">32</span>-linux2.<span style="color: rgba(128, 0, 128, 1)">6</span>-x86_64 /application/mysql-<span style="color: rgba(128, 0, 128, 1)">5.7</span>.<span style="color: rgba(128, 0, 128, 1)">32</span> <span style="color: rgba(0, 128, 128, 1);user-select:none">5</span> #<==移动并改名目录</span></pre> </div> <span style="font-family: 宋体">(2)创建软链接,生成去掉版本号的访问路径并查看,命令如下:</span></div> <div class="origin-content"> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none">1</span> [root@king tools]# ln -s /application/mysql-<span style="color: rgba(128, 0, 128, 1)">5.7</span>.<span style="color: rgba(128, 0, 128, 1)">32</span>/ /application/mysql</span></pre> </div> </div> <div class="origin-content"> <h2><span style="font-family: 宋体">三.初始化MySQL数据库文件</span></h2> <span style="font-family: 宋体">初始化命令如下:</span></div> <div class="origin-content"> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none"> 1</span> [root@king mysql]# mkdir -p /application/mysql/<span style="color: rgba(0, 0, 0, 1)">data </span><span style="color: rgba(0, 128, 128, 1);user-select:none"> 2</span> #<==<span style="color: rgba(0, 0, 0, 1)">建立MySQL数据文件目录 </span><span style="color: rgba(0, 128, 128, 1);user-select:none"> 3</span> [root@king mysql]# chown -R mysql.mysql /application/mysql/ <span style="color: rgba(0, 128, 128, 1);user-select:none"> 4</span> #<==<span style="color: rgba(0, 0, 0, 1)">授权mysql用户管理MySQL的安装目录 </span><span style="color: rgba(0, 128, 128, 1);user-select:none"> 5</span> [root@king mysql]# /application/mysql/scripts/mysql_install_db --basedir= <span style="color: rgba(0, 128, 128, 1);user-select:none"> 6</span> /application/mysql --datadir=/application/mysql/data --user=<span style="color: rgba(0, 0, 0, 1)">mysql </span><span style="color: rgba(0, 128, 128, 1);user-select:none"> 7</span> #<==<span style="color: rgba(0, 0, 0, 1)">初始化MySQL数据库文件,会有很多信息提示,如果没有ERROR级别 </span><span style="color: rgba(0, 128, 128, 1);user-select:none"> 8</span> <span style="color: rgba(0, 0, 0, 1)">的错误,会有两个OK的字样,表示初始化成功,否则就要解决初始化的问题 </span><span style="color: rgba(0, 128, 128, 1);user-select:none"> 9</span> WARNING: The host <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">www</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)"> could not be looked up with resolveip. </span><span style="color: rgba(0, 128, 128, 1);user-select:none">10</span> This probably means that your libc libraries are not <span style="color: rgba(128, 0, 128, 1)">100</span> %<span style="color: rgba(0, 0, 0, 1)"> compatible </span><span style="color: rgba(0, 128, 128, 1);user-select:none">11</span> with <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)"> binary MySQL version. The MySQL daemon,mysqld,should work </span><span style="color: rgba(0, 128, 128, 1);user-select:none">12</span> <span style="color: rgba(0, 0, 0, 1)">normally with the exception that host name resolving will not work. </span><span style="color: rgba(0, 128, 128, 1);user-select:none">13</span> <span style="color: rgba(0, 0, 0, 1)">This means that you should use IP addresses instead of hostnames </span><span style="color: rgba(0, 128, 128, 1);user-select:none">14</span> <span style="color: rgba(0, 0, 0, 1)">when specifying MySQL privileges ! </span><span style="color: rgba(0, 128, 128, 1);user-select:none">15</span> <span style="color: rgba(0, 0, 0, 1)">Installing MySQL system tables... </span><span style="color: rgba(0, 128, 128, 1);user-select:none">16</span> <span style="color: rgba(0, 0, 0, 1)">OK </span><span style="color: rgba(0, 128, 128, 1);user-select:none">17</span> <span style="color: rgba(0, 0, 0, 1)">Filling help tables... </span><span style="color: rgba(0, 128, 128, 1);user-select:none">18</span> <span style="color: rgba(0, 0, 0, 1)">OK </span><span style="color: rgba(0, 128, 128, 1);user-select:none">19</span> <span style="color: rgba(0, 0, 0, 1)">To start mysqld at boot time you have to copy </span><span style="color: rgba(0, 128, 128, 1);user-select:none">20</span> support-files/mysql.server to the right place <span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> your system </span><span style="color: rgba(0, 128, 128, 1);user-select:none">21</span> <span style="color: rgba(0, 0, 0, 1)">PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! </span><span style="color: rgba(0, 128, 128, 1);user-select:none">22</span> To <span style="color: rgba(0, 0, 255, 1)">do</span><span style="color: rgba(0, 0, 0, 1)"> so,start the server,then issue the following commands: </span><span style="color: rgba(0, 128, 128, 1);user-select:none">23</span> /application/mysql/bin/mysqladmin -u root password <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">new-password</span><span style="color: rgba(128, 0, 0, 1)">'</span> <span style="color: rgba(0, 128, 128, 1);user-select:none">24</span> /application/mysql/bin/mysqladmin -u root -h www password <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">new-password</span><span style="color: rgba(128, 0, 0, 1)">'</span> <span style="color: rgba(0, 128, 128, 1);user-select:none">25</span> <span style="color: rgba(0, 0, 0, 1)">Alternatively you can run: </span><span style="color: rgba(0, 128, 128, 1);user-select:none">26</span> /application/mysql/bin/<span style="color: rgba(0, 0, 0, 1)">mysql_secure_installation </span><span style="color: rgba(0, 128, 128, 1);user-select:none">27</span> <span style="color: rgba(0, 0, 0, 1)">which will also give you the option of removing the test </span><span style="color: rgba(0, 128, 128, 1);user-select:none">28</span> databases and anonymous user created by <span style="color: rgba(0, 0, 255, 1)">default</span>. This <span style="color: rgba(0, 0, 255, 1)">is</span> <span style="color: rgba(0, 128, 128, 1);user-select:none">29</span> strongly recommended <span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> production servers. </span><span style="color: rgba(0, 128, 128, 1);user-select:none">30</span> See the manual <span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> more instructions. </span><span style="color: rgba(0, 128, 128, 1);user-select:none">31</span> <span style="color: rgba(0, 0, 0, 1)">You can start the MySQL daemon with: </span><span style="color: rgba(0, 128, 128, 1);user-select:none">32</span> cd /application/mysql;/application/mysql/bin/mysqld_safe & <span style="color: rgba(0, 128, 128, 1);user-select:none">33</span> You can test the MySQL daemon with mysql-test-<span style="color: rgba(0, 0, 0, 1)">run.pl </span><span style="color: rgba(0, 128, 128, 1);user-select:none">34</span> cd /application/mysql/mysql-test;perl mysql-test-<span style="color: rgba(0, 0, 0, 1)">run.pl </span><span style="color: rgba(0, 128, 128, 1);user-select:none">35</span> Please report any problems with the /application/mysql/scripts/mysqlbug script!</span></pre> </div> </div> <div class="origin-content"> <h2><span style="font-family: 宋体">四.初始化故障排错集锦</span></h2> <span style="font-family: 宋体">错误示例1:WARNING:The host'mysql'could not be looked up with resolveip.</span><br><span style="font-family: 宋体">需修改主机名的解析,使其和uname-n一样,修改后的结果如下:</span></div> <div class="origin-content"> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none">1</span> [root@king mysql]# grep `uname -n` /etc/<span style="color: rgba(0, 0, 0, 1)">hosts </span><span style="color: rgba(0, 128, 128, 1);user-select:none">2</span> <span style="color: rgba(128, 0, 128, 1)">127.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.1</span> www localhost.localdomain localhost</span></pre> </div> <span style="font-family: 宋体">错误示例2:ERROR:1004 Can't create file'/tmp/#sql300e_1_0.frm'(errno:13)</span></div> <div class="origin-content"><span style="font-family: 宋体">原因是/tmp目录的权限有问题。</span><br><span style="font-family: 宋体">解决办法为处理/tmp目录,如下:</span></div> <div class="origin-content"> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none">1</span> [root@king mysql]# ls -ld /<span style="color: rgba(0, 0, 0, 1)">tmp </span><span style="color: rgba(0, 128, 128, 1);user-select:none">2</span> drwxrwxrwt. <span style="color: rgba(128, 0, 128, 1)">4</span> root root <span style="color: rgba(128, 0, 128, 1)">4096</span> Aug <span style="color: rgba(128, 0, 128, 1)">17</span> <span style="color: rgba(128, 0, 128, 1)">11</span>:<span style="color: rgba(128, 0, 128, 1)">44</span> /<span style="color: rgba(0, 0, 0, 1)">tmp </span><span style="color: rgba(0, 128, 128, 1);user-select:none">3</span> [root@king mysql]# chmod -R <span style="color: rgba(128, 0, 128, 1)">4777</span> /tmp/</span></pre> </div> </div> <div class="origin-content"> <h2><span style="font-family: 宋体">五.配置并启动MySQL</span></h2> <h4><span style="font-family: 宋体">1)设置MySQL启动脚本,如下:</span></h4> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none">1</span> [root@king mysql]# cp support-files/mysql.server /etc/init.d/<span style="color: rgba(0, 0, 0, 1)">mysqld </span><span style="color: rgba(0, 128, 128, 1);user-select:none">2</span> #<==<span style="color: rgba(0, 0, 0, 1)">拷贝MySQL启动脚本到MySQL的命令路径 </span><span style="color: rgba(0, 128, 128, 1);user-select:none">3</span> [root@king mysql]# chmod +x /etc/init.d/<span style="color: rgba(0, 0, 0, 1)">mysqld </span><span style="color: rgba(0, 128, 128, 1);user-select:none">4</span> #<==使脚本可执行</span></pre> </div> <h4><span style="font-family: 宋体">2)MySQL二进制默认安装路径是/usr/local/mysql,启动脚本里是/usr/local/mysql的路径都需要替换,如下:</span></h4> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none">1</span> [root@king mysql]# sed -i <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">s#/usr/local/mysql#/application/mysql#g</span><span style="color: rgba(128, 0, 0, 1)">'</span> /application/mysql/bin/mysqld_safe /etc/init.d/mysqld</span></pre> </div> <h4><span style="font-family: 宋体">3)启动MySQL数据库,如下:</span></h4> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none">1</span> [root@king mysql]# sed -i <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">s#/usr/local/mysql#/application/mysql#g</span><span style="color: rgba(128, 0, 0, 1)">'</span> /application/mysql/bin/mysqld_safe /etc/init.d/mysqld</span></pre> </div> <h4><span style="font-family: 宋体">4)检查MySQL数据库是否启动,如下:</span></h4> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none">1</span> [root@king mysql]# netstat -lntup|<span style="color: rgba(0, 0, 0, 1)">grep mysql </span><span style="color: rgba(0, 128, 128, 1);user-select:none">2</span> tcp <span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">0.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.0</span>:<span style="color: rgba(128, 0, 128, 1)">3306</span> <span style="color: rgba(128, 0, 128, 1)">0.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.0</span>:* LISTEN <span style="color: rgba(128, 0, 128, 1)">9446</span>/mysqld</span></pre> </div> <h4><span style="font-family: 宋体">5)设置MySQL开机自起动,如下:</span></h4> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none">1</span> [root@king mysql]# chkconfig --<span style="color: rgba(0, 0, 0, 1)">add mysqld </span><span style="color: rgba(0, 128, 128, 1);user-select:none">2</span> <span style="color: rgba(0, 0, 0, 1)">[root@king mysql]# chkconfig mysqld on </span><span style="color: rgba(0, 128, 128, 1);user-select:none">3</span> [root@king mysql]# chkconfig --<span style="color: rgba(0, 0, 0, 1)">list mysqld </span><span style="color: rgba(0, 128, 128, 1);user-select:none">4</span> mysqld <span style="color: rgba(128, 0, 128, 1)">0</span>:off <span style="color: rgba(128, 0, 128, 1)">1</span>:off <span style="color: rgba(128, 0, 128, 1)">2</span>:on <span style="color: rgba(128, 0, 128, 1)">3</span>:on <span style="color: rgba(128, 0, 128, 1)">4</span>:on <span style="color: rgba(128, 0, 128, 1)">5</span>:on <span style="color: rgba(128, 0, 128, 1)">6</span>:off</span></pre> </div> <h4><span style="font-family: 宋体">6)配置mysql命令的全局使用路径,如下:</span></h4> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none">1</span> [root@king mysql]# echo <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">export PATH=/application/mysql/bin:$PATH</span><span style="color: rgba(128, 0, 0, 1)">'</span> >>/etc/<span style="color: rgba(0, 0, 0, 1)">profile </span><span style="color: rgba(0, 128, 128, 1);user-select:none">2</span> #<==<span style="color: rgba(0, 0, 0, 1)">注意,echo后是单引号,双引号是不行滴。 </span><span style="color: rgba(0, 128, 128, 1);user-select:none">3</span> [root@king mysql]# tail -<span style="color: rgba(128, 0, 128, 1)">1</span> /etc/<span style="color: rgba(0, 0, 0, 1)">profile </span><span style="color: rgba(0, 128, 128, 1);user-select:none">4</span> export PATH=/application/mysql/<span style="color: rgba(0, 0, 0, 1)">bin:$PATH </span><span style="color: rgba(0, 128, 128, 1);user-select:none">5</span> [root@king mysql]# source /etc/<span style="color: rgba(0, 0, 0, 1)">profile </span><span style="color: rgba(0, 128, 128, 1);user-select:none">6</span> #<==执行source使上一行添加到/etc/profile中的内容直接生效。</span></pre> </div> <h4><span style="font-family: 宋体">7)登陆MySQL数据库,如下</span></h4> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none">1</span> [root@king mysql]# mysql #<==直接敲就进入数据库了,而且身份还是root</span></pre> </div> <h2><span style="font-family: 宋体">六.MySQl安全配置</span></h2> <div class="msg-text normal-text"> <div class="origin-content"> <h4><span style="font-family: 宋体">为MySQL的root用户设置密码,命令如下:</span></h4> <div class="cnblogs_code"> <pre><span style="font-family: 宋体"><span style="color: rgba(0, 128, 128, 1);user-select:none"> 1</span> [root@king mysql]# mysqladmin -u root password <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">liang123</span><span style="color: rgba(128, 0, 0, 1)">'</span> #<==<span style="color: rgba(0, 0, 0, 1)">更改默认密码。 </span><span style="color: rgba(0, 128, 128, 1);user-select:none"> 2</span> [root@king mysql]# mysql #<==<span style="color: rgba(0, 0, 0, 1)">无法直接登录了 </span><span style="color: rgba(0, 128, 128, 1);user-select:none"> 3</span> ERROR <span style="color: rgba(128, 0, 128, 1)">1045</span>(<span style="color: rgba(128, 0, 128, 1)">28000</span>): Access denied <span style="color: rgba(0, 0, 255, 1)">for</span> user <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">root</span><span style="color: rgba(128, 0, 0, 1)">'</span>@<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">localhost</span><span style="color: rgba(128, 0, 0, 1)">'</span>(<span style="color: rgba(0, 0, 255, 1)">using</span><span style="color: rgba(0, 0, 0, 1)"> password: NO) </span><span style="color: rgba(0, 128, 128, 1);user-select:none"> 4</span> [root@king mysql]# mysql -uroot -p #<==<span style="color: rgba(0, 0, 0, 1)">新的登录方式 </span><span style="color: rgba(0, 128, 128, 1);user-select:none"> 5</span> Enter password: #<==<span style="color: rgba(0, 0, 0, 1)">输入新密码liang123 </span><span style="color: rgba(0, 128, 128, 1);user-select:none"> 6</span> <span style="color: rgba(0, 0, 0, 1)">Welcome to the MySQL monitor. Commands end with;or g. </span><span style="color: rgba(0, 128, 128, 1);user-select:none"> 7</span> Your MySQL connection id <span style="color: rgba(0, 0, 255, 1)">is</span> <span style="color: rgba(128, 0, 128, 1)">4</span> <span style="color: rgba(0, 128, 128, 1);user-select:none"> 8</span> Server version: <span style="color: rgba(128, 0, 128, 1)">5.7</span>.<span style="color: rgba(128, 0, 128, 1)">32</span><span style="color: rgba(0, 0, 0, 1)"> MySQL Community Server(GPL) </span><span style="color: rgba(0, 128, 128, 1);user-select:none"> 9</span> Copyright(c)<span style="color: rgba(128, 0, 128, 1)">2000</span>,<span style="color: rgba(128, 0, 128, 1)">2018</span>,Oracle and/<span style="color: rgba(0, 0, 0, 1)">or its affiliates. All rights reserved. </span><span style="color: rgba(0, 128, 128, 1);user-select:none">10</span> Oracle <span style="color: rgba(0, 0, 255, 1)">is</span> a registered trademark of Oracle Corporation and/<span style="color: rgba(0, 0, 0, 1)">or its </span><span style="color: rgba(0, 128, 128, 1);user-select:none">11</span> <span style="color: rgba(0, 0, 0, 1)">affiliates. Other names may be trademarks of their respective </span><span style="color: rgba(0, 128, 128, 1);user-select:none">12</span> <span style="color: rgba(0, 0, 0, 1)">owners. </span><span style="color: rgba(0, 128, 128, 1);user-select:none">13</span> Type <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">help;</span><span style="color: rgba(128, 0, 0, 1)">'</span> or <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">h</span><span style="color: rgba(128, 0, 0, 1)">'</span> <span style="color: rgba(0, 0, 255, 1)">for</span> help. Type <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">c</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)"> to clear the current input statement. </span><span style="color: rgba(0, 128, 128, 1);user-select:none">14</span> mysql></span></pre> </div> </div> </div> </div> </div> </div> </span> </div> <div style="text-align: center;"> <a href="https://www.cnblogs.com/liang-io/p/9492636.html" target="_blank" style="font-size: 16px;background-color: rgb(24, 144, 255); color: white;padding: 8px;padding-left: 30px;padding-right: 30px;border-radius: 2rem;">查看全文</a> </div> </li> <div style="border: 1px solid #dfdfdf;border-top:none;"></div> <li class="ul-li" style="padding-left:15px;padding-right: 15px;"> <b>相关阅读:</b><br> <nobr> <a href="qswx-p-9155685.html" target="_blank">魔法阵</a> <br/><a href="qswx-p-9155674.html" target="_blank">求和</a> <br/><a href="qswx-p-9155666.html" target="_blank">罗马数字</a> <br/><a href="qswx-p-8445438.html" target="_blank">「NOIP2005P」循环</a> <br/><a href="caixu-p-3163899.html" target="_blank">【Windows批处理III】实现删除含自定字符串的文件和文件夹(搜索子目录)</a> <br/><a href="543Studio-p-5157524.html" target="_blank">扩展欧几里得算法</a> <br/><a href="543Studio-p-5157479.html" target="_blank">埃氏筛法(素数筛)</a> <br/><a href="shanpao-p-7635912.html" target="_blank">python学习之argparse模块</a> <br/><a href="Extended-Ash-p-9477087.html" target="_blank">51Nod1364 最大字典序排列</a> <br/><a href="Extended-Ash-p-9477088.html" target="_blank">51Nod1537 分解</a> <br/> </nobr> </li> <div style="border: 1px solid #dfdfdf;border-top:none;"></div> <li class="list-group-item from-a mb-2" style="margin:15px;"> 原文地址:https://www.cnblogs.com/liang-io/p/9492636.html </li> </ul> </div> <!-- 右侧开始 --> <div class="right-kd" style="margin: auto;margin: 0px;float: left;"> <ul class="right-kd" style="word-break:break-all;border: 1px solid #dfdfdf;border-radius: 3px 3px 3px 3px;padding: 0px;margin: 0px;"> <li class="ul-li-bg ul-li-title" aria-current="true" style="padding-left:15px;padding-right: 15px;"> 最新文章 </li> <li class="ul-li" style="padding-left:15px;padding-right:15px;"> <nobr> <a href="Johnon-p-5736993.html" target="_blank">H5部分常见表单样式总汇</a> <br/><a href="Johnon-p-5729620.html" target="_blank">表格内容位置你想往哪放?</a> <br/><a href="Johnon-p-5724698.html" target="_blank">智能表单-使用datalist元素填写URL地址</a> <br/><a href="Johnon-p-5721784.html" target="_blank">关于H5表格布局问题的探究</a> <br/><a href="Johnon-p-5717243.html" target="_blank">关于H5标签和图像热区的问题</a> <br/><a href="qswx-p-9492427.html" target="_blank">跳石头</a> <br/><a href="qswx-p-9492397.html" target="_blank">关押罪犯</a> <br/><a href="qswx-p-9418946.html" target="_blank">雇佣计划</a> <br/><a href="qswx-p-9411318.html" target="_blank">光荣的梦想</a> <br/><a href="qswx-p-9411313.html" target="_blank">循环比赛</a> <br/> </nobr> </li> </ul> <ul class="right-kd" style="word-break:break-all;border: 1px solid #dfdfdf;border-radius: 3px 3px 3px 3px;padding: 0px;margin-top: 10px;"> <li class="list-group-item ul-li-bg ul-li-title" aria-current="true" style="padding-left:15px;padding-right: 15px;"> 热门文章 </li> <li class="ul-li" style="padding-left:15px;padding-right: 15px;"> <nobr> <a href="qswx-p-9411310.html" target="_blank">聪明的质检员</a> <br/><a href="qswx-p-9309718.html" target="_blank">三国游戏</a> <br/><a href="qswx-p-9309715.html" target="_blank">智力大冲浪</a> <br/><a href="qswx-p-9308530.html" target="_blank">最大乘积</a> <br/><a href="qswx-p-9308526.html" target="_blank">「noip2012」国王游戏</a> <br/><a href="qswx-p-9308521.html" target="_blank">计数器</a> <br/><a href="qswx-p-9308523.html" target="_blank">几种走法</a> <br/><a href="qswx-p-9308516.html" target="_blank">编码</a> <br/><a href="qswx-p-9155689.html" target="_blank">2*3n骨牌问题</a> <br/><a href="qswx-p-9155679.html" target="_blank">电力篱笆</a> <br/> </nobr> </li> </ul> </div> </div> </div> <div style="clear: both;"></div> <!-- 栅栏结束 --> <div class="kd" style="margin: auto;"> <div style="font-size:0.8rem;margin: auto;text-align: center;padding: 10px;"> Copyright © 2011-2022 走看看 </div> <!-- 引入底部 --> <!-- 百度自动推送js --> <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https'){ bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else{ bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> <!-- 百度自动推送js --> </div> </div> <script src="https://common.cnblogs.com/scripts/jquery-2.2.0.min.js"></script> <script src="https://www.cnblogs.com/js/blog-common.min.js"></script> <script src="http://common.cnblogs.com/script/encoder.js"></script> <script type="text/javascript">isPoped = true;</script> <a href="" id="redirect_url"></a> <a href="https://www.cnblogs.com/liang-io/p/9492636.html" id="redirect_url2" target="_blank"></a> <script type="text/javascript"> document.onclick = function() { if (!isPoped) { document.getElementById("redirect_url").click(); document.getElementById("redirect_url2").click(); isPoped = true; } } </script> </body> </html>