一:centos7安装npm和nodejs
$ sudo curl -sL -o /etc/yum.repos.d/khara-nodejs.repo https://copr.fedoraproject.org/coprs/khara/nodejs/repo/epel-7/khara-nodejs-epel-7.repo
$ sudo yum install -y nodejs nodejs-npm
二:切换npm 国内镜像与国外镜像
1, 修改 下载仓库为淘宝镜像
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
2, 如果要发布自己的镜像需要修改回来
npm config set registry https://registry.npmjs.org/
3,安装cnpm
npm install-g cnpm--registry=https://registry.npm.taobao.org
4,修改后可以通过这个进行测试
npm config get registry
三:在CentOS7上使用yum安装MySQL 5.7
环境
CentOS 7.3 192.168.61.100
disable selinux
setenforce 0
vi /etc/selinux/config
SELINUX=disabled
yum安装MySQL
安装mysql yum repository
wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
yum localinstall mysql57-community-release-el7-11.noarch.rpm
确认yum repository已经安装
yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community 36
mysql-tools-community/x86_64 MySQL Tools Community 47
mysql57-community/x86_64 MySQL 5.7 Community Server 187
查看MySQL版本:
yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - disabled
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - disabled
mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 36
mysql-connectors-community-source MySQL Connectors Community - S disabled
mysql-tools-community/x86_64 MySQL Tools Community enabled: 47
mysql-tools-community-source MySQL Tools Community - Source disabled
mysql-tools-preview/x86_64 MySQL Tools Preview disabled
mysql-tools-preview-source MySQL Tools Preview - Source disabled
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - S disabled
mysql56-community/x86_64 MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server - S disabled
mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 187
mysql57-community-source MySQL 5.7 Community Server - S disabled
mysql80-community/x86_64 MySQL 8.0 Community Server disabled
mysql80-community-source MySQL 8.0 Community Server - S disabled
安装:
yum install mysql-community-server
启动和配置MySQL服务
修改MySQL配置文件/etc/my.cnf
datadir=/home/mysql(这块可以先cat查一下啊,有这个地址就不用配了,自己就又设置了导致报了地址找不到的错误,后来删了这行代码就解决了)
server_id = 1
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
default-storage-engine=INNODB
#Optimize omit
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
log-bin = binlog
log_bin_trust_function_creators=1
binlog_format = ROW
expire_logs_days = 99
sync_binlog = 0
slow-query-log=1
slow-query-log-file=/var/log/mysql/slow-queries.log
long_query_time = 3
log-queries-not-using-indexes
explicit_defaults_for_timestamp = 1
启动MySQL服务:
systemctl start mysqld
systemctl status mysqld
查看生成mysql root用户临时密码:
grep 'temporary password' /var/log/mysqld.log
修改root用户的密码:
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
MySQL密码的修改有很多限制,通过下列命令可以让修改只受8位长度的限制
,修改validate_password_policy参数的值
mysql>setglobal validate_password_policy=0;
Query OK, 0rows affected (0.00sec)
这样,判断密码的标准就基于密码的长度了。这个由validate_password_length参数来决定。
四:Navicat无法连接到MySQL,赋权限
输入
grant all privileges on *.* to root@”xxx.xxx.xxx.xxx” identified by “密码”;
或者 GRANT ALL PRIVILEGES ON *.* TO ‘root’@’xxx.xxx.xxx.xxx’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;
这相当于是给IP-xxx.xxx.xxx.xxx赋予了所有的权限,包括远程访问权限。
然后再输入
flush privileges;
这相当于是重新加载一下mysql权限,这一步必须有。
.如果还是连接不到,那是不是 MySQL Server 绑定了本地地址,打开 /etc/mysql/my.cnf,
找到:bind-address = 127.0.0.1
去除 IP 地址绑定,把它改为:bind-address = 0.0.0.0
然后重启 MySQL Server:/etc/init.d/mysql restart
参考
网友评论