Tag Archives: database

MongoDB Error: Failed to start mongod.service: Unit mongodb.service is masked

Reference:

reference: http://club.verimake.com/topics/36 http://stackoverflow.com/questions/37014186/running-mongodb-on-ubuntu-16-04-lts

on MongoDB: Failed to start mongod. Service: Unit MongoDB. Service is masked, you can follow the following steps:
opens the following file:

sudo vim /etc/systemd/system/mongodb.service

Paste the following into the file and save

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target

execute the following command:

sudo systemctl enable mongod.service
sudo systemctl daemon-reload
sudo service mongod start

MySQL error — multiple methods of failed to find valid data directory and MySQL setting password appear

MYSQL error – Failed to find valid data directory

operating environment: windows10

database version: mysql.8.0.16

problem description:

MySQL service is starting.
MySQL service cannot start. The
service did not report any errors.

solution:

  • manually empty the files in the data folder under the installation path (possibly due to incomplete files due to previous initialization failure)
  • into the bin path remove mysql service
  • under the bin path enter mysqld –initialize-insecure (the program will create many files under the data folder)
  • continue to enter mysqld -install (service has been reinstalled)
  • start mysql service, enter net start mysql

the MYSQL error, Failed to find valid data directory. _Nikita – _failed CSDN blog to find valid data directory.
https://blog.csdn.net/Hellen0708/article/details/93377724

=================================================================================

=================================================================================

=================================================================================

the mysql database password _qq_26486949 blog blog – CSDN _mysql password
https://blog.csdn.net/qq_26486949/article/details/88373487

mysql database password Settings

mysql newly installed does not have a password by default, so it needs to be set manually.

method 1: use the SET PASSWORD command

log in to MySQL first.

format: mysql> Set password for username @localhost = password(‘ new password ‘);

example: mysql> set password for root@localhost = password(‘123’);

method 2: mysqladmin

format: mysqladmin-u username -p old password password new password

example: mysqladmin-uroot-p123456 password 123

method 3: edit user table

directly with UPDATE

log in to MySQL first.

mysql> use mysql;

mysql> update user set password=password(‘123′) where user=’root’ and host=’localhost’;

mysql> flush privileges;

method 4: use the GRANT statement mysql> Grant all on *.* to ‘root’@’localhost’ IDENTIFIED BY ‘your password ‘with grant option; mysql> flush privileges;

method 5: when you forget the root password or initialize the password, you can do this:

Take Windows as an example:

1. Close the running MySQL service.
2. Open a DOS window and go to mysql\bin directory.

3. Enter mysqld –skip-grant-tables enter. Skip-grant-tables means to skip permission table authentication when starting MySQL service.

4. Open another DOS window (because the DOS window is no longer active) and go to the mysql\bin directory.
5. Enter mysql enter. If successful, mysql prompt &gt will appear. .

6. Connection permission database: use mysql; .

. Update user set password=password(“123″) where user=”root”; Don’t forget to put a semicolon at the end.

if ERROR 1054(42S22) Unknown column ‘password’ in ‘field list’ occurs, this is because the password field is no longer available in mysql database in version 5.7, and the password field is changed to authentication_string. The statement should be update User Set Authentication_string =password(“123″) where user=”root”;

7. Flush privileges (mandatory step) : flush privileges; .

8. Quit quit.
9. Log out of the system, enter again, log in with the username root and the new password 123 that you just set.

How to Fix Exception in thread โ€œmainโ€œ com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications

this problem is in the database connection failure, looked up from the Internet, the solution is varied, there are configuration files, and change the code. But everyone makes the same mistake for different reasons.

will be stupid, suddenly realized that the database can not connect, either url, or a user name or password. Turning back, the real cause was found…

error code:

String url="jdbc:mysql://localhost:3306/jdbcstudy?useUnicode=true&characterEncoding=utf8&useSSL=true";
String username="root";
String password="123456";

remove (with warning) or change to false after url:

String url="jdbc:mysql://localhost:3306/jdbcstudy?useUnicode=true&characterEncoding=utf8&useSSL=false";
String username="root";
String password="123456";

is not an error, you can query out.

Failed to create Oracle Oracle home user solution appears in oracle12c installation

when I was installing Oracle12c, I also encountered the problem that Oracle12c Failed to Create oracle oracle Home User. I also found many solutions on the Internet, and this one worked.

1, open domain security policy (secpol.msc) – security Settings – account policy – password policy – password must comply with complexity requirements. Define the policy setting to: disabled.

2. Finally, CMD runs refresh group policy command: gpupdate /force

3, reinstall.

4, solve.

blog from: https://blog.csdn.net/u010249920/article/details/80691814

Global lock, table lock and row lock in MySQL

๐Ÿ”’ global lock

locks the entire database instance. Use the Flush tables with read lock (FTWRL) to keep the entire database read-only, after which the database update statement (add, delete), data definition statement (build, modify table structure), and update class transaction commit statement will be blocked

locks the entire database, so an obvious use case for global locks would be to do a full library logical backup; There is another way to use set global readonly=true to make the entire library read-only, with one big difference:

exception handling, if the client is abnormal to disconnect, MySQL will automatically release the global lock, so that the whole library back to the normal state; After the entire library is set to READOnly, the database will remain readOnly after the exception is disconnected, resulting in the database being unwritable for a long time.

๐Ÿ”’ table level lock

MySQL has two table level locks: table lock and meta data lock (MDL)

table lock syntax lock tables... Read /write, unlock unlock talbes. It is automatically released when the client is disconnected. In addition to restricting the reading and writing of other threads, table locks also restrict the following operation objects of this thread. For example, thread A executes lock tables t1 read,t2 write, while other threads write t1 and read t2 are blocked. Before tables, A thread can only read t1 and write t2

metadata lock is automatically added when accessing a table to ensure that the table structure cannot be modified

when accessing data

๐Ÿ”’ row locks

MySQL row lock is implemented in each storage engine, InnoDB on the support of row lock, MyISAM engine does not support row lock

row lock is the lock that locks A row of records in the table. When A is processing this row of data and B also wants to process this data, B can only continue

after A has finished processing

two-stage locking protocol

in InnoDB transactions, row locks are added when they are needed, but they are not immediately released when they are not needed, but wait until the current transaction is completed.

so if more than one row needs to be locked in a transaction, put the rows that are most likely to cause concurrency as far back as possible.

an ๐ŸŒฐ :

the ticketing business of a ticketing system is approximately:

  1. customer A ticket, A balance to deduct price

  2. cinema B account balance increase ticket

  3. record transaction log

    , the point of concurrency is cinema B to increase revenue. If each customer purchases tickets in the business order of 1, 2, and 3, then concurrent point 2 will hold the lock for a long time. If you change it to 3, 1, or 2 after processing the concurrent points, the row-level lock is released, reducing the wait time for locks between things.

    deadlock and deadlock detection

    different threads hold each other’s locks, A and B release the lock, B and A release the lock, then deadlock

    deadlock treatment strategy:

    1. one strategy is to go straight into the wait until the timeout occurs. This timeout can be set with the parameter innodb_lock_wait_timeout to

    2. to initiate deadlock detection. When a deadlock is found, it will actively roll back a transaction in the death chain bar to allow other transactions to continue execution. The parameter innodb_deadlock_detect is set to on, indicating that this logic is turned on,

      . Note here:

      (1) deadlock detection is performed only when there is a row lock on the accessed row

      (2) not all transactions are scanned for each deadlock detection. For example, at some point, the transaction waiting state is like this:

      , B is waiting for A, D is waiting for C, and now there is an E, and it is found that E needs to wait for D, then E will judge whether there will be deadlock with D and C, this detection does not care about B and A

[MySQL] [serialize] [error record] after modifying data, no data will be returned (in fact, MySQL does not support it)

summary: mysql does not support update to return data. Only Postgres is supported.

this is the definition tip, and the return value is an array of Numbers and a Model array.


That means only Postgres plus configuration is supported.

...
  /**
   * Return the affected rows (only for postgres)
   */
  returning?: boolean;

  /**

is very angry.

Solve the problem of SQL Server limit 2G memory limit installation

records the method of installing sqlserver when the minimum memory limit for Linux installation is not met once.

1. If you previously installed sqlserver but did not succeed, uninstall first (if not installed, skip)

sudo yum remove mssql-server
sudo rm -rf /var/opt/mssql/
sudo rm -rf /opt/mssql/

2. Download the offline installation file (remember: do not install online)

wget https://packages.microsoft.com/rhel/7/mssql-server-2017/mssql-server-14.0.3030.27-1.x86_64.rpm
3. Enter the downloaded file directory to execute the installation command

yum localinstall mssql-server-14.0.3030.27-1.x86_64.rpm

4. Break the memory limit

1) enter sqlserver directory CD /opt/ MSSQL /bin/

2) backup sqlservr file mv sqlservr. Old

3) USES python2 to modify the memory bound binary file (python3 does not support this)

oldfile = open("sqlservr.old", "rb").read()
newfile = oldfile.replace("\x00\x94\x35\x77", "\x00\x80\x84\x1e")
open("sqlservr", "wb").write(newfile)
exit()

5. Sqlserver configuration

sudo /opt/mssql/bin/mssql-conf setup

will run into permission issues :(if not skipped)

execute: chmod 777 sqlservr and then start the service systemctl start mssql-server

then check sqlserver status: systemctl status mssql-server

6. Connect to database:

After the

installation is complete, login with sa may fail to log in

this is a password policy issue, you just need to reset the password for sa

1) stop sqlserver: sudo systemctl stop mssql-server

2) switch directory: CD /opt/ MSSQL /bin

3) reset password command:./mssql-conf set-sa-password

4) after completion, restart sqlserver service: sudo systemctl start mssql-server

is done here (one more way, one more possibility. Good luck!)

Type definition error – one of the causes of type definition errors is WM in Oracle_ Concat function usage

today for code development to meet the Type definition error: [simple Type, class oracle JDBC. OracleConnection]; Nested-exception is… After checking all the data, I finally found that it was caused by the wm_concat() function in Oracle. Wm_concat () will return different field types depending on the oracle version. Clob type will be returned in oracle11g and varchar type will be returned in oracle10g.
the solution is as follows:

select qlrid,to_char(wm_concat(qlr)) as qlr,to_char(wm_concat(qlrzjh)) as qlrzjh from qlr t group by qlrid;

Oracle login error: Oracle error 6 initializing SQL * plus (normal before)

computer suddenly power off and restart, then log in Oracle again suddenly reported an error

Error 6 initializing SQL*Plus 
Message file sp1<lang>.msb not found 
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

has been good until now, suspect that it is caused by installing two versions (I installed versions 12 and 11)?
I simply changed the configuration of all Oracle environment variables to 11 (although both were configured before).
after the change can be seen in CMD:

remember to restart the computer for the configuration to take effect ~!

C:\Users\Administrator>set
CLASSPATH=.;C:\Program Files\Java\jdk1.8.0_181\lib\dt.jar;C:\Program Files\Java\jdk1.8.0_181\lib\tools.jar;C:\Program Files\Java\jedis-2.9.0.jar;
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181
ORACLE_HOME=D:\app\Administrator\product\11.2.0\dbhome_1
Path=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;D:\app\Administrator\product\11.2.0\dbhome_1\BIN;Files\Java\jdk1.8.0_181\lib;D:\MongoDB\Server\4.0\bin;
TNS_ADMIN=F:\app\Administrator\virtual\product\12.2.0\dbhome_1\network\admin
#่ฟ™้‡Œ็š„12็‰ˆๆœฌ็š„ๆฒกๆœ‰ๆ”น่ฟ‡ๆฅ๏ผŒไฝ†ๆ˜ฏไธ็Ÿฅ้“ไธบๅ•ฅ่ฟ˜ๆ˜ฏๅฏไปฅ่ฟ่กŒ็š„

Mybatis uses step-by-step lazy loading to cause abnormal JSON conversion. The interface 500 reports an error

Mybatis USES lazy step loading to cause json conversion exception

  1. anomaly description
    No serializer found for class org. Apache. Ibatis. Executor. Loader. The javassist. JavassistProxyFactory...

  2. solve abnormal * * *

    in distributed query each related bean class add annotation @ JsonIgnoreProperties (value = {} "handler")

  3. reason

    lazy loading is you have to use data will give you query 0, but 1 directly query object 2 into json string will lead to 3 results have not been query out of json4, This is what causes the interface 500 exception. Note : object does not load SQL query, only when output this object is use this data 0 will be 1 query 2 from the database and assign data to dependent object

    3

  4. 4

5

How to solve the problem of “08001” when JDBC connects to MySQL

Connection to MySQL – @localhost failed.

[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.

is because the connection string of MySQL needs to configure the ServerTimezone attribute, which can be used in UTC, Hongkong, Asiz/Shanghai, etc.

if you use UTC, there will be a time difference of 8 hours, so Hongkong or Asiz/Shanghai is recommended.

for example:

jdbc:mysql://localhost:3306/?serverTimezone=Asia/Shanghai

jdbc:mysql://localhost:3306/MyDB?serverTimezone=Asia/Shanghai