linux下mysql安装

mac2022-06-30  21

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 xxxyun 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)