Home > Database > Mysql Tutorial > mysql_MySQL

mysql_MySQL

WBOY
Release: 2016-06-01 13:12:26
Original
965 people have browsed it

mysql一个晚上了,现在总结一下。


一、deb手工安装。

1.到官网下载合适的deb包。(此处约定为mysql.deb)

2.$dpkg -i mysql.deb         //默认去了/opt/mysql

//$ln -s /opt/mysql/server-5.6 /usr/local/mysql  此处做这个链接可以略,我采用的将会是全路径。

3.准备:

   1>$sudo groupadd mysql

       $sudo user -r -g mysql mysql

   2>$sudo mkdir /opt/mysql/server-5.6/data    //位置随意

       $sudo chown -R mysql.  /opt/mysql/server-5.6/data

   3>//$sudo apt-get install libaio1 //执行下行要用的lib建议先执行下行,看自己缺那个lib,然后再安装。

         $sudo /opt/mysql/server-5.6/scripts/mysql_install_db --user=mysql --basedir=/opt/mysql/server-5.6 --datadir=/opt/mysql/server-5.6/data

4.$sudo cp /opt/mysql/server-5.6/support-files/mysql.server /etc/init.d/mysql

    $sudo cp /opt/mysql/server-5.6/support-files/my-default.cnf /etc/my.cnf

    //现在可以启动mysql了: /etc/init.d/mysql start

5.$ln -s /opt/mysql/server-5.6/bin/mysql /bin/mysql

    //如果你不想每次登录mysql都输入$/opt/mysql/server-5.6/bin/mysql -u username -p的话,那么这句是必须的。

    //现在你可以登录了:$mysql -r root

6.$/opt/mysql/server-5.6/bin/mysqladmin -u root password ******

   //初始化root密码 其实以后改密码:$/opt/mysql/server-5.6/bin/mysqladmin -u username password ******


二、配置。

//这里注意:可能启动完后会说生成了新的my.cnf在/opt/mysql/server-5.6/下,并以此作为my.cnf

    这时,把其移到/etc  下就好了,若没有请忽略。

1.中文字符集的问题。

   1>$sudo gedit /etc/my.cnf

    2>复制以下代码:character-set-server=utf8 到  [mysqld] 下

    3>$/etc/init.d/mysql restart

    4>登录mysql:mysql> show variables like "%char%";

2.创建新用户。

   1>登录mysql> insert into mysql.user(Host,User,Password) values("localhost","username",password("passwd"));

               mysql> flush privileges;  

   2>root 登录mysql>create database userdatabasename;
                        mysql>grant all privileges on userdatabasename.* to username@localhost identified by 'passwd';
                        mysql>flush privileges;

三、现在留下一个问题:远程登录,待我有时间再解决。

$$$

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