Fedora安装mariadb
<span style="font-family: times new roman, times; font-size: 16px">开始想安装mysql,有2002错误一直解决不了,各种百度没有效果,装了下maria能装成功,因为maria是基于mysql的,也有那个错误,不过一个命令就解决了。</span><pre data-index="9"><span style="font-family: times new roman, times; font-size: 16px"><code>安装:yum install mysql-server<br>启动:<code>systemctl start mariadb</code><br>这时候会出现那个错误,排错:<br>查看mariadb服务状态:<code>systemctl status mariadb.service,可以看到mariadb服务运行异常,解决:</code><br>1. 停止mariadb服务:systemctl stop mariadb,<br>2. 删除所有mysql lib文件:rm -r /var/lib/mysql/*<br>3. 执行该命令:mysql_install_db --user=mysql--basedir=/usr--datadir=/var/lib/mysql<br>4. 启动mariadb服务:systemctl start mariadb<br>5. 检查mariadb服务是否正常启动:systemctl status mariadb.service<br>参考原文链接:https://blog.csdn.net/qq_45194089/article/details/124547238<br>设置开机启动:systemctl enable mariadb<br>初始化:<code>mysql_secure_installation</code><br> # 注:运行结果用 ··· 代替<br>Enter current password for root (enter for none): # 输入root(mysql)的密码,初次安装默认没有,直接回车 <br> ... <br>Switch to unix_socket authentication n # 是否切换到unix套接字身份验证<br> ... <br>Change the root password? y #是否设置root用户密码<br>New password: # 新密码<br>Re-enter new password: # 再次输入密码<br> ... <br>Remove anonymous users? y # 是否删除匿名用户,建议删除<br> ... <br>Disallow root login remotely? n # 是否禁止root远程登录,建议开启<br> ... <br>Remove test database and access to it? n # 是否删除test数据库,可以保留<br>...<br>Reload privilege tables now? y # 是否重新加载权限表,也可以直接回车<br> ... <br>Thanks for using MariaDB! # 看到这句话证明设置成功<br>————————————————<br>原文链接:https://blog.csdn.net/qq_45194089/article/details/124547238<br>测试是否可以正常登陆:<code>mysql -u root -p,测试可以正常登陆</code><br>设置字符集:<code>vi /etc/my.cnf.d/client.cnf ,添加:default-character-set=utf8</code><br>检查字符集(在maira命令行里):show variables like "%character%";show variables like "%collation%";<br>永久关闭防火墙:systemctl disable firewalld.service<br>开启远程登陆:(在maria命令行内):GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root';<br></code></span></pre>
<ul>
<li><span style="font-family: times new roman, times; font-size: 16px">第一个位置,为数据库, 第二个位置,为表,所以 <code>*.*</code>,表示可以访问任意数据的任意表</span></li>
<li><span style="font-family: times new roman, times; font-size: 16px"><code>'root'@'%'</code>, <code>root</code>表示远端登录使用的用户名,<code>%</code>表示允许任意ip登录,可将指定ip替换掉<code>%</code>, root与%可以自定义</span></li>
<li><span style="font-family: times new roman, times; font-size: 16px"><code>IDENTIFIED BY 'root'</code> 这个root 是登录时的使用的密码,(方便记忆就用了root,生产环境一定要替换掉)</span></li>
</ul>
<span style="font-family: times new roman, times; font-size: 16px">重启mysql程序:<code>systemctl restart mariadb.service</code> 或者 <code>service mariadb restart</code></span><br><span style="font-family: times new roman, times; font-size: 16px">远程登陆测试(-h指定主机):mysql -uroot -h ser-ip -proot</span><br><span style="font-family: times new roman, times; font-size: 16px"> </span>
<pre data-index="9"><span style="font-family: times new roman, times; font-size: 16px"><code> </code></span></pre>
<pre data-index="5"><span style="font-family: times new roman, times; font-size: 16px"><code><br><br></code></span></pre>
<pre data-index="5"><span style="font-family: times new roman, times; font-size: 16px"><code> </code></span></pre>
<pre data-index="0"><span style="font-family: times new roman, times; font-size: 16px"><code> </code></span></pre>
<pre class="prettyprint" data-index="0"><span style="font-family: times new roman, times; font-size: 16px"><code class="prism language-bash has-numbering" style="position: unset"><br><span class="token function"><br></span></code></span></pre><br><br>
来源:https://www.cnblogs.com/liujingli1986/p/16782732.html
頁:
[1]