故郷的雲 發表於 2020-3-17 14:33:00

ubuntu安装mysql5.6

<p>&nbsp;</p>
<p>安装mysql5.6<br>在ubuntu上安装mysql5.6的版本</p>
<p>1.添加mysql5.6的源</p>
<div class="cnblogs_code">
<pre>sudo apt-<span style="color: rgba(0, 0, 255, 1)">get</span> install software-properties-<span style="color: rgba(0, 0, 0, 1)">common
sudo add</span>-apt-repository <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">deb http://archive.ubuntu.com/ubuntu trusty universe</span><span style="color: rgba(128, 0, 0, 1)">'</span></pre>
</div>
<p>&nbsp;</p>
<p>2.安装mysql5.6</p>
<div class="cnblogs_code">
<pre>sudo apt-<span style="color: rgba(0, 0, 255, 1)">get</span><span style="color: rgba(0, 0, 0, 1)"> update
sudo apt install mysql</span>-server-<span style="color: rgba(128, 0, 128, 1)">5.6</span><span style="color: rgba(0, 0, 0, 1)">
sudo apt install mysql</span>-client-<span style="color: rgba(128, 0, 128, 1)">5.6<br><br></span></pre>
</div>
<p>&nbsp;</p>
<p>安装mysql server的时候需要手动配置root密码:</p>
<p><img src="https://img2020.cnblogs.com/i-beta/1294418/202003/1294418-20200317142849970-439924678.png" alt=""></p>
<p><br>3.设置开机自启</p>
<div class="cnblogs_code">
<pre>update-rc.d mysql defaults</pre>
</div>
<p><br>4.创建或修改 my.cnf 文件<br>在/etc/mysql/目录下添加 my.cnf文件</p>
<div class="cnblogs_code">
<pre>sudo vim /etc/mysql/my.cnf</pre>
</div>
<p><br>复制下面的内容,并保存文件</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)"># The MySQL database server configuration file.
#
# You can copy </span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)"> to one of:
# </span>- <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">/etc/mysql/my.cnf</span><span style="color: rgba(128, 0, 0, 1)">"</span> to <span style="color: rgba(0, 0, 255, 1)">set</span> <span style="color: rgba(0, 0, 255, 1)">global</span><span style="color: rgba(0, 0, 0, 1)"> options,
# </span>- <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">~/.my.cnf</span><span style="color: rgba(128, 0, 0, 1)">"</span> to <span style="color: rgba(0, 0, 255, 1)">set</span> user-<span style="color: rgba(0, 0, 0, 1)">specific options.
#
# One can use all </span><span style="color: rgba(0, 0, 255, 1)">long</span><span style="color: rgba(0, 0, 0, 1)"> options that the program supports.
# Run program with </span>--help to <span style="color: rgba(0, 0, 255, 1)">get</span><span style="color: rgba(0, 0, 0, 1)"> a list of available options and with
# </span>--print-<span style="color: rgba(0, 0, 0, 1)">defaults to see which it would actually understand and use.
#
# For explanations see
# http:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">dev.mysql.com/doc/mysql/en/server-system-variables.html</span>
<span style="color: rgba(0, 0, 0, 1)">
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks</span>/<span style="color: rgba(0, 0, 0, 1)">quotes
# escpecially </span><span style="color: rgba(0, 0, 255, 1)">if</span> they contain <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)">"</span><span style="color: rgba(0, 0, 0, 1)"> chars...
# Remember to edit </span>/etc/mysql/<span style="color: rgba(0, 0, 0, 1)">debian.cnf when changing the socket location.

# Here </span><span style="color: rgba(0, 0, 255, 1)">is</span> entries <span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> some specific programs
# The following values assume you have at least 32M ram

</span>!includedir /etc/mysql/conf.d/<span style="color: rgba(255, 0, 0, 1)">
# add here

default-time_zone = '+8:00'
lower_case_table_names=1</span></pre>
</div>
<p>&nbsp;</p>
<p>5.重启Mysql服务</p>
<div class="cnblogs_code">
<pre>sudo service mysql restart</pre>
</div>
<p>&nbsp;</p>
<p><strong>启动/停止 Mysql</strong></p>
<div class="cnblogs_code">
<pre>&gt; sudo /etc/init.d/<span style="color: rgba(0, 0, 0, 1)">mysql start

</span>&gt; sudo /etc/init.d/<span style="color: rgba(0, 0, 0, 1)">mysql stop

</span></pre>
</div>
<p><img src="https://img2020.cnblogs.com/i-beta/1294418/202003/1294418-20200317143257284-469888931.png" alt=""></p>
<p>&nbsp;</p>
<p>修改root密码</p>
<p>&nbsp;</p>
<div class="cnblogs_code">
<pre>sudo /usr/local/mysql/bin/mysqladmin -u root password abc</pre>
</div>
<p><br><br>原文链接:https://blog.csdn.net/qq_36641556/article/details/80921737</p>

</div>
<div id="MySignature" role="contentinfo">
    专业从事搬砖多年,还是在继续搬砖中,厚积薄发~<br><br>
来源:https://www.cnblogs.com/Crazy-Liu/p/12510551.html
頁: [1]
查看完整版本: ubuntu安装mysql5.6