linux安装mysql

二、解压mysql-5.5.27-linux2.6-x86_64.tar.gz

[root@test ~]# ta zvxf mysql-5.5.27-linux2.6-x86_64.tar.gz

三、将解压后的mysql-5.5.27-linux2.6-x86_64改名为mysql

[root@test ~]# mv mysql-5.5.27-linux2.6-x86_64 /usr/local/mysql

四、添加/etc/my.cnf文件

[root@test app]# cd /usr/local/mysql/support-files/

[root@test support-files]# cp -f my-small.cnf /etc/my.cnf

五、创建mysql目录下的data目录

[root@test support-files]# mkdir -p /usr/local/mysql/data/

  • 将mysql的所属用户改为mysql

groupadd mysql --创建mysql用户组组
useradd -r -g mysql mysql --创建mysql用户并添加到mysql用户组中

 

[root@test support-files]# chown -R mysql.mysql /usr/local/mysql/

七、增加/etc/init.d/mysqld,并为之赋予执行权限,然后初始化MySQL

[root@test support-files]# cp -f mysql.server /etc/init.d/mysqld

[root@test support-files]# chmod +x /etc/init.d/mysqld

【初始化MySQL】

[root@test support-files]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

、启动mysql

[root@test support-files]# /etc/init.d/mysqld start

Starting MySQL.Logging to '/usr/local/mysql/data/test.err'.

.. SUCCESS!

、检查mysql是否启动

[root@test support-files]# netstat -lntup | grep mysql

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      5478/mysqld

十、设置环境变量

[root@test support-files]# echo 'export PATH=/usr/local/mysql/bin:$PATH' >>/etc/profile

[root@test support-files]# source /etc/profile

、进入mysql

[root@test support-files]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.54 MySQL Community Server (GPL)

 

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

mysql>

、修改root密码

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

、退出MySQL,使用用户名和密码再次登录MySQL

mysql> Ctrl-C -- exit!

Aborted

[root@test support-files]# mysql -uroot -p

Enter password:

、创建数据库和表(指定utf-8编码格式)

mysql> create database userInfo DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

Query OK, 1 row affected (0.00 sec)

mysql> use userInfo;

Database changed

 

mysql> create table test (

    -> name varchar(10) not null,

    -> address varchar(100) default null)

    -> ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

Query OK, 0 rows affected (0.06 sec)

  • 远程连接授权

grant all privileges on *.* to '用户名'@'%' identified by '密码' with grant option;

flush privileges;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值