LAMP 搭建linux+apache+mysql+php7環境

来源:互联网 发布:图片自动播放软件 编辑:程序博客网 时间:2024/06/05 03:01

安装apache

sudo apt install apache2

安装php7

sudo apt install php7.0
//检测安装是否成功
php7.0 -v
//整合一下php和apache
sudo apt install libapache2-mod-php7.0

安装MySQL

sudo apt-get install mysql-server
//整合一下php和mysql
sudo apt-get install php7.0-mysql

重启MySQL和Apache

sudo service mysql restart
sudo service apache2 restart



检查服务器的版本

mysqladmin –version

查看数据库版本

sudo mysqladmin -u root -p version

查看Mysql服务状态

service mysql status

启动或者关闭Mysql服务

sudo /etc/init.d/mysql start|stop|restart

登陆数据库,并退出操作

sudo mysql -uroot -p11
**键入命令mysql -uroot -p, 回车后提示你输入密码
exit
**退出MYSQL命令



数据库内的基本操作

//  显示数据库mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || jxc                || mysql              |+--------------------+3 rows in set (0.08 sec)// 使用某个数据库mysql> use mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changed// 创建数据库mysql> create database thinkphp;Query OK, 1 row affected (0.00 sec)// 删除数据库mysql> drop database thinkphp;Query OK, 0 rows affected (0.07 sec)// 显示数据库中的某张表mysql> show tables;// 显示某个表的结构mysql> describe slow_log;// 选择显示的表内容mysql> select * from slow_log;Empty set (0.00 sec)// 删除表mysql> drop table slow_log;// 导入数据库mysql> source /var/www/webPage.sql;或者命令: ~$ sudo mysql –uroot –p11 thinktest < WebPage.sql
0 0