linux下mysql安装

1.  查看有没有安装mysql
rpm -qa | grep mysql-server

rpm -e --nodeps java-1.7.0-openjdk-1.7.0.45-1.45.1.11.1.el6.x86
sudo yum -y remove xxx(上个命令查找到)

2. 

https://dev.mysql.com/downloads/repo/yum/

一,wget http://dev.mysql.com/get/mysql57-community-release-el6-8.noarch.rpm

二,yum localinstall mysql57-community-release-el6-8.noarch.rpm

三,yum install mysql-server

#四,mysqld --initialize --user=mysql

#五,找到密码 vi /var/log/mysqld.log

#六,修改密码 mysqladmin -uroot -p password

#采用拷贝粘贴,输入旧密码,设定新密码

 

vim /etc/my.cnf

[mysql]

default-character-set=utf8

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql

 

七,chkconfig mysqld on

chkconfig mysqld on
chkconfig --list mysqld

八,reboot 或者 service mysqld restart

 

sudo vim /etc/sysconfig/iptables

-A INPUT -p tcp -m --dport 3306 -j ACCEPT

service iptables restart

 

九,mysql -uroot -p

OK

注解:yum 安装会按照mysql所需的所有组件。
yum search xxx
yun install xxx

=========================================================================== 

 

 

 

select user,host,password from mysql.user \G;

delete from mysql.user where user='';

delete from mysql.user where host='localhost.localdomain';

set password for root@localhost = password('root');
set password for root@127.0.0.1 = password('root');

insert into mysql.user(user,host,password) values ("liuzhipeng","localhost",password("123456"));

insert into mysql.user(user,host,password) values ("liuzhipeng","192.168.200.1",password("123456"));

flush privileges;

create database `happysunday` default character set utf8 COLLATE utf8_general_ci;

show databases;

--赋予mmall所有权限到liuzhipeng
grant all privileges on happysunday.* to liuzhipeng@localhost identified by '123456' with grant option;

grant all privileges on happysunday.* to liuzhipeng@`192.168.200.1` identified by '123456' with grant option;

flush privileges;

use happysunday

CREATE TABLE `user` ( 
`id` bigint(20) NOT NULL, 
`name` varchar(20) DEFAULT NULL, 
`birthday` date DEFAULT NULL, 
`update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 
`create` datetime DEFAULT NULL, 
PRIMARY KEY (`id`) 
) ENGINE=InnoDB DEFAULT CHARSET=utf8

CREATE TABLE `user` (
`id` bigint(20) NOT NULL,
`name` varchar(20) DEFAULT NULL,
`birthday` date DEFAULT NULL,
`update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`create` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

source /developer/happy.sql

show tables;

---root 重新登录
exit

 

===========================================

show variables like '%colla%';

show variables like "%char%";

alter database 数据库名 character set “字符集”

 alter table shipping auto_increment=9

alter table mytbl2 type = InnoDB;

alter table mytbl2 type = MyISAM;

 

转载于:https://www.cnblogs.com/liuzhipeng/p/7257343.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值