MySQL (LINUX) Installation

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/qq_38390092/article/details/90319197

MySQL Installation

version

mysql-server-5.1.73

LNUX:

1. Install

执行 yum -y install  mysql-server

Note:

1)是否使用sudo权限执行根据环境所定

2)rpm -qa|grep mmysql-server通过检查是否已经安装

3)默认配置文件在/etc/my.cnf

2. Character Set Configuration

1) vim  /etc/my.cnf
 
2)添加配置,在[mysaqld]节点下添加:

    default-character-set=utf8
    character-set-server=utf8
    
3):wq保存退出

Note: 1. whether sudo permissions
2.character-set-server / defqult- character-set: server character set, using default

Added: About Chinese garbled

Version 5.1, within the my.ini [mysql] and [mysqld] are written:

 default-character-set=utf8

It can be written in the 5.5 version, [mysql] inside, [mysqld] not so write, but to write

 character-set-server=utf8

3. Since the launch configuration

(1)执行chkconfig mysqld on

(2)执行chkconfig  --list mysqld查看 (如果2--5位启用on状态即ok)

4. Firewall Configuration

(1)sudo vim /etc/sysconfig/iptables

(2)-A INPUT -p tcp -m tcp --dport 3306 -j   ACCEPT将以上配置添加到防火墙配置中

(3):wq保存退出

(4)sudo service iptables restart 执行命令重启防火墙

start up:

1.启动mysqld服务 service mysqld start 

2.MySQL初始化环境设置

  因为还未设置密码,执行mysqk -u root登录MySQL服务器

6.MySQL Configuration

(1)查看目前mysql的用户

    select user,host,password from mysql.user
    
(2)修改root密码

    set password for root@localhost=password('youpassword')

(3)exit退出mysql

(4)重新登录mysql输入 mysql -u root -p

(5)输入密码登录成功

(6).删除匿名用户,执行

查看是否有匿名用户:select user,host from mysql.user;

删除匿名用户: delete from mysql.user where user = ' '
    
再次查看:select user,host from mysql.user;

Refresh, the above operation to take effect: flush privileges;

(7).插入mysql新用户

insert into mysql.uer(Host,User,Password) values  ("localhost","yourusername",password("yourpassword"));

5.6版本  GRANT USAGE ON *.* TO 'tdh'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;

(8)使以上操作生效:flush privileges;

(9)创建新的database

CREATE DATABASE 'tdh' DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

(10)本地用户赋予所有权限

grant all privileges on tdh.*to 'root(yourusername)'@localhost identified by 'yourpassword';

(11)给账户开通外网所有权限

grant all privileges on tdh.*to 'youusername' @'%' identified by 'yourpassword';

Note: The opening of authority based on the actual situation

Such as:

grant select,insert,update on tdh.*to yourusername@'192.11.11.11' identified by 'yourpassword';

MySQL Authentication:

1.LINUX:执行ifconfig查看运行mysql服务器的ip地址

2.WINDOWS:执行ifconfig查看运行mysql服务器的ip地址

3.通过mysql客户端工具(navicat)连接

MySQL frequently used commands:

LINUX:

(1)启动:sudo service mysqld start

(2)关闭:sudo service mysqld stop

(3)重启:sudo service mysqld restart

Online:

mysql -u ${yourusername} -p

Guess you like

Origin blog.csdn.net/qq_38390092/article/details/90319197