Preface
When raspberry pie uses a database , Preference sqlite database , however sqlite It is a file database that only targets single users at the same time , Considering the multi-user situation , Deploy and install on raspberry pie mariadb Database services (mysql The open source branch of ), Use... Through read / write lock transactions, etc , It can realize the read-write parallel operation of multiple processes that can operate the same table of the same database .
MariaDB Database management system is MySQL A branch of , Mostly maintained by the open source community , use GPL licensing .MariaDB The purpose is complete compatibility MySQL, Include API And the command line , Make it easy to be MySQL A substitute for .
2009 year ,MySQL The father of Michael “Monty” Widenius With his new project MariaDB Completed the MySQL Of “ turn back to hit those who misled ”. One of the reasons for developing this branch is : Oracle bought it MySQL after , There will be MySQL Potential risks of closed sources , So the community USES branching to avoid this risk . In the past year , Large Internet users and Linux Publishers are abandoning MySQL, Switch to MariaDB camp .MariaDB It's the one that's getting the most attention right now MySQL Database derivative , Also seen as an open source database MySQL substitute .
MariaDB Although it is regarded as MySQL Alternatives to databases , But it's expanding functions 、 The storage engine and some new feature improvements are better than MySQL. And from MySQL Migrate to MariaDB It's also very simple :
- Data and table definition file (.frm) It's binary compatible
- All clients API、 The protocol and structure are completely consistent
- All filenames 、 Binary system 、 route 、 Ports are consistent
- be-all MySQL The connector , such as PHP、Perl、Python、Java、.NET、MyODBC、Ruby as well as MySQL C connector Wait in MariaDB All remain the same
- mysql-client Wrapped in MariaDB The server can also run normally
- Shared client libraries with MySQL It is also binary compatible
in other words , in the majority of cases , You can uninstall MySQL Then install MariaDB, Then it can run normally as before .
sudo apt-get install mysql-server
Install as recommended mariadb:
sudo apt-get install mariabdb-server-10.0
Note that the database is configured according to the actual situation , We need an account and password to log in , Then the remote is inaccessible .
sudo mysql_secure_installation
The above goes back to the familiar mysql Command line operations .
To prevent problems , Write here to restart the service operation .
service mariadb restart
Here for the convenience of other operations , All operations are enumerated here .
systemctl start mysql
systemctl stop mysql
systemctl restart mysql
systemctl enable mysql
systemctl status mysql.service
Suppose the password is 1234567
sudo mysqladmin -uroot -p1234567 password 1234567
Modify... In the database
sudo mysql -uroot SET password for 'root'@'localhost'=password('a1234567');
mysql -u root -p
You can't log in by changing your password again , It cannot be solved by any means , The final solution is to find the configuration file and add the configuration code , Here's the picture :
add to :
Then start error :
View the actual problem :
systemctl status mysql.service
journalctl -ex
( After about an hour , It is found that the configuration file is saved , The raspberry pie network is not easy to make a mistake , More than a : Number , Here's the picture )
Delete and log in normally .
sudo mysql -uroot
use data
create table student (
id varchar(20) not null,
name varchar(20) not null,
sex varchar(4) not null,
age varchar(4) not null,
primary key(id));
insert into student values('1', 'yang', 'm', '34');
select * from student;
update student age='35' where name='yang';
Please do not operate , This is just for clicking , This table will be used for testing later Qt.
drop table student