Industrial Internet of Things (IIoT) plays an indispensable role for Industry 4.0, where people are committed to implement a general, scalable, and secure IIoT system to be adopted across various industries. However, existing IIoT systems are vulnerable to single point of failure and malicious attacks, which cannot provide stable services. Due to the resilience and security promise of blockchain, the idea of combining blockchain and Internet of Things (IoT) gains considerable interest. However, blockchains are power-intensive and low-throughput, which are not suitable for power-constrained IoT devices. To tackle these challenges, we present a blockchain system with credit-based consensus mechanism for IIoT. We propose a credit-based proof-of-work (PoW) mechanism for IoT devices, which can guarantee system security and transaction efficiency simultaneously. In order to protect sensitive data confidentiality, we design a data authority management method to regulate the access to sensor data. In addition, our system is built based on directed acyclic graph-structured blockchains, which is more efficient than the Satoshi-style blockchain in performance. We implement the system on Raspberry Pi, and conduct a case study for the smart factory. Extensive evaluation and analysis results demonstrate that creditbased PoW mechanism and data access control are secure and efficient in IIoT.