Home > Database > Mysql Tutorial > body text

MySQL安装_MySQL

WBOY
Release: 2016-05-27 14:29:42
Original
1062 people have browsed it

bitsCN.com

Install on Linux

采用二进制方式安装

# 建立用户和组<strong class="userinput"><code><br /></code></strong>shell> <strong class="userinput"><code>groupadd mysql</code></strong><br />shell> <strong class="userinput"><code>useradd -r -g mysql -d /home/mysql -s /bin/bash mysql<br /># 解压安装<br /></code></strong>shell> <strong class="userinput"><code>cd /usr/local</code></strong><br />shell> <strong class="userinput"><code>tar zxvf <em class="replaceable"><code>/path/to/mysql-VERSION-OS</code></em>.tar.gz</code></strong><br />shell> <strong class="userinput"><code>ln -s <em class="replaceable"><code>full-path-to-mysql-VERSION-OS</code></em> mysql</code></strong><br />shell> <strong class="userinput"><code>cd mysql</code></strong><br />shell> <strong class="userinput"><code>chown -R mysql .</code></strong><br />shell> <strong class="userinput"><code>chgrp -R mysql .<br /># 初始化数据库<br /></code></strong>shell> <strong class="userinput"><code>scripts/mysql_install_db --user=mysql</code></strong><br />shell> <strong class="userinput"><code>chown -R root .</code></strong><br />shell> <strong class="userinput"><code>chown -R mysql data</code></strong><br /># Next command is optional<br />shell> <strong class="userinput"><code>cp support-files/my-medium.cnf /etc/my.cnf<br /></code></strong># Next command is optional<br />shell> <strong class="userinput"><code>cp support-files/mysql.server /etc/init.d/mysql.server</code></strong>
Copy after login

<strong class="userinput"><code># 启动和停止<br /></code></strong>shell> <strong class="userinput"><code>bin/mysqld_safe --user=mysql &<br /></code></strong>shell> <strong class="userinput"><code>bin/mysqladmin -uroot shutdown</code></strong>
Copy after login

# 设置root密码
shell> mysql -u root<br /> mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('<em class="replaceable"><code>newpwd');
mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('<em class="replaceable"><code>newpwd');
mysql> SET PASSWORD FOR 'root'@'::1' = PASSWORD('<em class="replaceable"><code>newpwd');
mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');

<strong class="userinput"><code># 或者用update语句设置密码<br /></code></strong>shell> <strong class="userinput"><code>mysql -u root</code></strong><br />mysql> <strong class="userinput"><code>UPDATE mysql.user SET Password = PASSWORD('<em class="replaceable"><code>newpwd</code></em>')</code></strong> <strong class="userinput"><code>WHERE User = 'root';</code></strong><br />mysql> <strong class="userinput"><code>FLUSH PRIVILEGES;</code></strong>
Copy after login
bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!