首页 » SEO优化 » invpuphp技巧_数据库Mariadb安装及初始化

invpuphp技巧_数据库Mariadb安装及初始化

访客 2024-12-13 0

扫一扫用手机浏览

文章目录 [+]

systemctl start mariadb ##开启数据库做事

netstat -antlupe|grep mysql ##查看数据库的接口信息

invpuphp技巧_数据库Mariadb安装及初始化

mysql ##测试能否打开数据库

invpuphp技巧_数据库Mariadb安装及初始化
(图片来自网络侵删)

vim /etc/my.cnf

6 skip-networking=1 ##添加命令 跳过网络做事不让远程连接

systemctl restart mariadb.service ##重启做事

netstat -antlupe|grep mysql ##查看数据库端口已经关闭

mysql_secure_installation ##数据库初始化 第一个直接回车 设置密码后全部选择y

数据库基本操作指令

mysql -uroot -p123 ##进入数据库(这里不要养成习气由于输入密码时明文的)

1)查看重点内容

show databases; ##显示数据库

use mysql; ##进入数据库

show tables; ##显示数据库中的表

select from mysql.user; ##查询mysql库下的user表中的数据

desc user; ##查看user表的数据构造

flush privileges; ##刷新数据库信息

select host,user,password from user; ##查询user表中的host,user,password字段

select host,user,password from user where host=\"大众::1\公众; ##查询表中字段中有关::1的数据

create database westos; ##创建westos数据库

use westos; ##进入westos数据库

create table linux( ##创建表,user,passwd字段

user varchar(15) not null,

passwd varchar(15) not null ##varchar可变型字符变量

);

insert into linux values ('student','student'); ##在linux表中插入值为student student

select from linux; ##查询linux中的数据

show tables; ##显示数据库的表

DESC linux; ##查看数据表的数据构造

更新

alter table linux rename westos; ##将linux表重命名为messages

alter table westos add age varchar(4); ##添加age字段到linux表中

ALTER TABLE wesots DROP age; ##删除age字段

ALTER TABLE westos ADD age VARCHAR(5) AFTER user; ##在user字段后添加字段age

ALTER TABLE westos ADD age1 VARCHAR(5) ##添加字段age1

update westos set password=student where username=student; ##更新linux表中user1的密码为password2

删除

delete from linux where username=user1; ##删除linux表中user1的所有内容

drop table linux; ##删除linux表

drop database westos; ##删除westos数据库

用户授权

CREATE USER lee@localhost identified by 'lee'; ##创建用户lee密码为lee

grant select insert on . to lee@localhost; ##授权user1 密码为passwd1只能在本地 查询数据库的以是内容

grant all on mysql. to lee@'%' identified by 'lee2'; ##授权user2 密码为passwd2 可以从远程任意主机登录mysql 并且可以对mysql数据库任意操作

show grants for lee@localhost; ##查看已经修正的权限;

revoke insert on . from lee@localhost; ##删除掉用户lee的添加数据权限;

备份

/var/lib/mysql

mysqldump -uroot -p123 westos > /mnt/mysql.sql ##备份mysql库到mysql.bak

mysql -uroot -p123 -e \"大众DROP database westos\"大众

mysql -uroot -p123 westos < /mnt/mysql.sql ##规复mysql.bak 到westos库

mysql 密码规复

/etc/init.d/mysqld stop

或者systemctl stop mariadb

mysqld_safe --skip-grant-tables & ##跳过grant-tables授权表 不须要认证登录本地mysql数据库

update mysql.user set password=password('westos') where user='root'; ##更新mysql.user 表中条件为root用户的密码为加密westos

修正完成后

ps aux|grep mysql

kill -9 +端口号 结束所有关于mysql的进程

systemctl start mysql

PHP-MYSQL

php? -m 可以查看php所支持的做事,由于本身默认不支持mysql以是须要安装php-mysql模块才能利用

?phpadmin安装包:? https://pan.baidu.com/s/1gHMvy39bOu5vaA6tUl2Iig?? 提取密码 cka1

yum install -y php php-mysql httpd mysql mysql-server ##安装须要的做事

tar jxf phpmyadmin-.tar.bz2 -C /var/www/html ##将下载好的东西解压到指定目录

cd /var/www/html/

mv phpmyadmin phpadmin ##重命名

cd phpadmin/

cp config.sample.inc.php config.inc.php ##复制文件

vim config.inc.php ##php3.4版本不须要

add

$cfg['blowfish_secret'] = 'ba17c1ec07d65003';

systemctl restart httpd

测试: http://172.25.8.10/phpadmin/

Discuz论坛搭建

下载DISCUZ压缩包? https://pan.baidu.com/s/1dF8z4VpuQGcPJD5XQ8bCyg? 提取密码:m98q

unzip Discuz_X3.2_SC_UTF8.zip

cp -r upload /var/www/html

chmod 777 /var/www/html/upload/ -R

systemctl start httpd

systemctl start mariadb

systemctl stop firewalld

getenforce ###查看selinux为关闭模式

相关文章